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

how to get the absolute pathname of the current shell?



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).
The goal is to set $SHELL to the current shell.

Currently I'm doing: ${$(whence -p ${0#-}):a}

But this doesn't work when there are symbolic links, for instance,
when one has:

  foo -> bar/subdir
  my_shell -> /bin/zsh

foo/../../my_shell executes my_shell as expected, but the ":a"
gives: /home/my_shell

Note that I have the CHASE_LINKS option set, but the solution
shouldn't depend on this setting.

I want something portable, thus I don't want to rely on a realpath
command or /proc.

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