From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1165 invoked from network); 19 May 1999 09:22:11 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 19 May 1999 09:22:11 -0000 Received: (qmail 24730 invoked by alias); 19 May 1999 09:22:02 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6313 Received: (qmail 24723 invoked from network); 19 May 1999 09:22:01 -0000 Message-Id: <9905190857.AA34194@ibmth.df.unipi.it> To: zsh-workers@math.gatech.edu, arnonk@microtal.com Subject: PATCH: 3.1.5-pws-18: Re: zsh bug, again In-Reply-To: "Peter Stephenson"'s message of "Mon, 17 May 1999 11:17:14 DFT." <9905170917.AA38979@ibmth.df.unipi.it> Date: Wed, 19 May 1999 10:57:31 +0200 From: Peter Stephenson Peter Stephenson wrote: > "Arnon Kanfi" wrote: > > I have discovered a bug in zsh 3.1.4 when used on SunOs. when doing an "su" > > The real > problem here is that zsh can't actually know what it should be emulating; > su might have exec'd an `sh' which happened to be zsh in disguise. Arnon pointed out you might as well use $SHELL to find out what's what, since su probably did to get the shell in the first place. So this does that. I'm still loath to change the $ZSH_NAME parameter from what it's been exec'd as. It depends if you think it should reflect the execution environment or the emulation; in most cases it reflects the former, and the emulation is just a side effect. But I'm not madly fixed on this. --- Doc/Zsh/compat.yo.su2 Mon May 17 11:13:36 1999 +++ Doc/Zsh/compat.yo Wed May 19 10:50:13 1999 @@ -12,11 +12,12 @@ name of the executable file, ignoring any initial `tt(-)' as well as `tt(r)' (for restricted); an `tt(s)' or `tt(b)' will force bf(sh) compatibility, while `tt(k)' will force bf(ksh) compatibility. An -exception is if the first two letters excluding any `tt(-)' are tt(su), in -which case no emulation will be performed; this is to workaround a problem -under some operating systems where the tt(su) command does not change the -name when executing a user shell. Note that, from within zsh itself, this -mechanism can be invoked by `tt(ARGV0=sh zsh ...)'. +exception is if the name excluding any `tt(-)' is tt(su), in which case +the environment variable tt(SHELL) will be used to test the emulation; +this is to workaround a problem under some operating systems where the +tt(su) command does not change the name when executing a user shell. Note +that, from within zsh itself, this mechanism can be invoked by `tt(ARGV0=sh +zsh ...)'. In this emulation mode, the following parameters are not special and not initialized by the shell: --- Src/options.c.su2 Mon May 17 10:53:26 1999 +++ Src/options.c Wed May 19 10:48:47 1999 @@ -438,6 +438,17 @@ { char ch = *zsh_name; + if (!strcmp("su", zsh_name)) { + /* We haven't set up the paramtable yet, so just use zgetenv */ + char *ptr = zgetenv("SHELL"); + if (ptr && *ptr) { + zsh_name = ptr; + if ((ptr = strrchr(zsh_name, '/'))) + zsh_name = ptr+1; + ch = *zsh_name; + } else + ch = 'z'; + } if (ch == 'r') ch = zsh_name[1]; @@ -446,7 +457,7 @@ emulation = EMULATE_CSH; else if (ch == 'k') emulation = EMULATE_KSH; - else if ((ch == 's' && zsh_name[1] != 'u') || ch == 'b') + else if (ch == 's' || ch == 'b') emulation = EMULATE_SH; else emulation = EMULATE_ZSH; -- Peter Stephenson Tel: +39 050 844536 WWW: http://www.ifh.de/~pws/ Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy