Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
how to get the absolute pathname of the current shell?
- X-seq: zsh-users 18199
- From: Vincent Lefevre <vincent@xxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: how to get the absolute pathname of the current shell?
- Date: Fri, 6 Dec 2013 14:27:51 +0100
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mail-followup-to: zsh-users@xxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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