Monday, 20 May 2013

Portable way to get script's absolute path?

Portable way to get script's absolute path?

What is a portable way for a (zsh) script to determine its absolute path?
On Linux I use something like
mypath=$(readlink -f $0)
...but this is not portable. (E.g., readlink on darwin does not recognize the -f flag, nor has any equivalent.) (Also, using readlink for this is, admittedly, pretty obscure-looking.)
What's a more portable way?

No comments:

Post a Comment