Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: how to get the absolute pathname of the current shell?



On Dec 6,  2:27pm, Vincent Lefevre wrote:
}
} I'd like to get an absolute pathname of the current shell, for
} interactive shells (i.e. scripts are not concerned), in a startup
} file (so that the current working directory has not changed).

As far as I can tell there is no portable way to do this.  Even C
programs have to use different code depending on the OS.

} Currently I'm doing: ${$(whence -p ${0#-}):a}
} 
} But this doesn't work when there are symbolic links

If the above is otherwise good enough, why not ${$(whence -p ${0#-}):A}
which uses realpath() when it is available?  [See above about different
code depending on OS ...]



Messages sorted by: Reverse Date, Date, Thread, Author