Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: 3.1.5-pws-18: Re: zsh bug, again
- X-seq: zsh-workers 6313
- From: Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx, arnonk@xxxxxxxxxxxx
- Subject: PATCH: 3.1.5-pws-18: Re: zsh bug, again
- Date: Wed, 19 May 1999 10:57:31 +0200
- In-reply-to: "Peter Stephenson"'s message of "Mon, 17 May 1999 11:17:14 DFT." <9905170917.AA38979@xxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
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 <pws@xxxxxxxxxxxxxxxxx> Tel: +39 050 844536
WWW: http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy
Messages sorted by:
Reverse Date,
Date,
Thread,
Author