zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ibmth.df.unipi.it>
To: zsh-workers@math.gatech.edu, arnonk@microtal.com
Subject: PATCH: 3.1.5-pws-18: Re: zsh bug, again
Date: Wed, 19 May 1999 10:57:31 +0200	[thread overview]
Message-ID: <9905190857.AA34194@ibmth.df.unipi.it> (raw)
In-Reply-To: "Peter Stephenson"'s message of "Mon, 17 May 1999 11:17:14 DFT." <9905170917.AA38979@ibmth.df.unipi.it>

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@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


      reply	other threads:[~1999-05-19  9:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-05-16 21:55 zsh bug Arnon Kanfi
1999-05-17  9:17 ` PATCH: 3.1.5-pws-18: " Peter Stephenson
1999-05-19  8:57   ` Peter Stephenson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9905190857.AA34194@ibmth.df.unipi.it \
    --to=pws@ibmth.df.unipi.it \
    --cc=arnonk@microtal.com \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).