cd $(dirname "$0")
greadlink shouldn't be necessary.
But later I realized there's a good reason: http://arclanguage.org/item?id=20641
-----