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.

The following code seems to work:

  tmp=$(whence -p ${0#-})
  SHELL=${${tmp##/*}:+$PWD/}$tmp

It avoids buggy symbolic link resolution.

-- 
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