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

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



On 2013-12-09 09:53:30 +0100, Vincent Lefevre wrote:
> On 2013-12-06 08:30:20 -0800, Bart Schaefer wrote:
> > On Dec 6,  2:27pm, Vincent Lefevre wrote:
> > } 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 ...]
> 
> Using :A instead of :a doesn't solve the problem.

After looking more closely, this is because "resolution of `..' occurs
before resolution of symbolic links" (see zshexpn(1) man page). Since
zsh's resolution of `..' is broken by design, i.e. incompatible with
real resolution, as done by realpath (and the Linux kernel), :A and :a
mustn't be used here.

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



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