From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25480 invoked by alias); 6 Dec 2013 13:40:09 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 18199 Received: (qmail 2296 invoked from network); 6 Dec 2013 13:40:04 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 Date: Fri, 6 Dec 2013 14:27:51 +0100 From: Vincent Lefevre To: zsh-users@zsh.org Subject: how to get the absolute pathname of the current shell? Message-ID: <20131206132751.GA6509@ypig.lip.ens-lyon.fr> Mail-Followup-To: zsh-users@zsh.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Mailer-Info: http://www.vinc17.net/mutt/ User-Agent: Mutt/1.5.21-6305-vl-r59709 (2013-04-16) 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 - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)