From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15133 invoked from network); 14 Apr 1997 21:00:44 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 14 Apr 1997 21:00:44 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id QAA13785; Mon, 14 Apr 1997 16:54:17 -0400 (EDT) Resent-Date: Mon, 14 Apr 1997 16:54:17 -0400 (EDT) Message-Id: <199704142054.QAA13764@euclid.skiles.gatech.edu> Date: 14 Apr 1997 15:51 EDT Sender: "Alain Caron" To: hzoli@vnet.IBM.COM Cc: coleman@math.gatech.edu, zsh-workers@math.gatech.edu From: "Alain Caron" Subject: Re: zsh not sourcing /etc/profile? MIME-version: 1.0 Content-type: text/plain; charset="ISO-8859-1" Content-transfer-encoding: quoted-printable Resent-Message-ID: <"5j4jM.0.KN3.vbfKp"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/3076 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu In message "Re: zsh not sourcing /etc/profile?", 'hzoli@vnet.IBM.COM' writes: >Richard Coleman wrote: >> I found this article on comp.unix.shells. I thought I would >> pass it along. >[...] >> > posix-sh, ksh, and bash all return the name of the shell for $0 when >> > sourcing a file. >> > >> > Only zsh returns the name of the file being sourced. I suspect the >> > right behaviour is to return the shell name. The reason for this is >> > that sourcing a file does not create a new process, it should behave >> > as if the file had been typed from the keyboard. If you type the >> > command "echo $0" at the prompt, it should return the shell name. >> > Although I really like zsh, I think it does not have the right >> > behaviour because you can't rely on $0 to determine which shell is >> > interpreting the file. > >Under zsh this is controlled by the FUNCTION_ARGZERO option, which is set >when zsh is started as sh/ksh. > >Zoltan > Even there, the behaviour is not the same as ksh. On HP-UX 9.05 under ksh: 1> echo $0 ksh 2> echo 'echo "$0"' > bar 3> . ./bar ksh 4> function foo { echo $0 } 5> foo foo under zsh : 1> echo $ZSH_VERSION 3.0.2 2> echo $0 zsh 3> [[ -o function_argzero ]] && echo "yes" || echo "no" yes 4> echo 'echo "$0"' >! bar 5> . ./bar ./bar 6> function foo { echo $0 } 7> foo foo 8> unsetopt function_argzero 9> [[ -o function_argzero ]] && echo "yes" || echo "no" no 10> . ./bar zsh 11> foo zsh 12> emulate ksh 13> . ./bar zsh 14> foo zsh The behaviour shown by ksh seems, IMHO, better than the one shown by zsh. The reason is that sourcing a file should have the same behaviour as typing the text. However, in a function, $0 is more useful as the name of the function than the name of the shell. Also, with emulate ksh, the behaviour of zsh is different than ksh. Shouldn't we change the behaviour of function_argzero option to behave more like ksh? Regards, Alain Caron Nortel Technology, Montr=E9al, Qu=E9bec, Canada email: alainc@nortel.ca