zsh-users
 help / color / mirror / code / Atom feed
* how to get the absolute pathname of the current shell?
@ 2013-12-06 13:27 Vincent Lefevre
  2013-12-06 16:30 ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Vincent Lefevre @ 2013-12-06 13:27 UTC (permalink / raw)
  To: zsh-users

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@vinc17.net> - 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)


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-12-09  9:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-06 13:27 how to get the absolute pathname of the current shell? Vincent Lefevre
2013-12-06 16:30 ` Bart Schaefer
2013-12-09  8:53   ` Vincent Lefevre
2013-12-09  9:31     ` Vincent Lefevre
2013-12-09  9:45     ` Vincent Lefevre

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).