From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26011 invoked from network); 29 Dec 2003 08:02:40 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 29 Dec 2003 08:02:40 -0000 Received: (qmail 26266 invoked by alias); 29 Dec 2003 08:02:16 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6964 Received: (qmail 26203 invoked from network); 29 Dec 2003 08:02:15 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 29 Dec 2003 08:02:15 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [68.1.17.114] by sunsite.dk (MessageWall 1.0.8) with SMTP; 29 Dec 2003 8:2:15 -0000 Received: from quark.localdomain ([68.12.75.33]) by lakemtao07.cox.net (InterMail vM.5.01.06.05 201-253-122-130-105-20030824) with ESMTP id <20031229080213.TICY2432.lakemtao07.cox.net@quark.localdomain> for ; Mon, 29 Dec 2003 03:02:13 -0500 Received: from quark.localdomain (localhost.localdomain [127.0.0.1]) by quark.localdomain (8.12.9/8.12.9) with ESMTP id hBT82MuO075515 for ; Mon, 29 Dec 2003 02:02:22 -0600 (CST) (envelope-from vince@quark.localdomain) Received: (from vince@localhost) by quark.localdomain (8.12.9/8.12.9/Submit) id hBT82Mph075514 for zsh-users@sunsite.dk; Mon, 29 Dec 2003 02:02:22 -0600 (CST) Date: Mon, 29 Dec 2003 02:02:22 -0600 From: Vincent Stemen To: zsh-users@sunsite.dk Subject: Possible bug in zsh Message-ID: <20031229080222.GA75453@quark.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i I think I may have encountered a bug in Z shell. It began when I tried linking /bin/sh to zsh on FreeBSD-5.1. When it reboots, I get a lot of errors from the init scripts because the rootfs does not get re-mounted read-writable. I have isolated the piece of init script code and included a small script below, extracted from the init scripts and modified for testing, that reproduces the problem. See the comments in the script. The problem goes away if I remove the [ -n "$_precmd" ] statement which, so far as I can tell, should have no effect on the following if statement where the problem is. I tested with zsh-4.0.9 and zsh-4.1.0.dev5. -- Vincent Stemen Avoid the VeriSign/Network Solutions domain registration trap! http://www.InetAddresses.net From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24842 invoked from network); 29 Dec 2003 09:21:38 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 29 Dec 2003 09:21:38 -0000 Received: (qmail 9331 invoked by alias); 29 Dec 2003 09:21:24 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6965 Received: (qmail 9261 invoked from network); 29 Dec 2003 09:21:24 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 29 Dec 2003 09:21:24 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [216.228.9.89] by sunsite.dk (MessageWall 1.0.8) with SMTP; 29 Dec 2003 9:21:23 -0000 Received: by binome.blorf.net (Postfix, from userid 1000) id EE53F2F98; Mon, 29 Dec 2003 01:21:22 -0800 (PST) Date: Mon, 29 Dec 2003 01:21:22 -0800 From: Wayne Davison To: Vincent Stemen Cc: zsh-users@sunsite.dk Subject: Re: Possible bug in zsh Message-ID: <20031229092122.GA23732@binome.blorf.net> References: <20031229080222.GA75453@quark.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20031229080222.GA75453@quark.localdomain> User-Agent: Mutt/1.5.4i On Mon, Dec 29, 2003 at 02:02:22AM -0600, Vincent Stemen wrote: > I think I may have encountered a bug in Z shell. Here's a simplified test case that better shows what's gone wrong: false; if eval ''; then echo one; fi true; if eval ''; then echo two; fi This outputs only "two" in zsh, but both "one" and "two" in bash. It appears that an eval of an empty string in zsh returns the return code of the last-run command. In your example script, the "[ -n ...]" part failed, so the following "if ! eval $empty ..." bit was executed as if the eval of the empty string had also failed. I also assume that this is a bug. ..wayne.. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25465 invoked from network); 1 Jan 2004 23:39:27 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 1 Jan 2004 23:39:27 -0000 Received: (qmail 810 invoked by alias); 1 Jan 2004 23:39:02 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6969 Received: (qmail 555 invoked from network); 1 Jan 2004 23:39:00 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 1 Jan 2004 23:39:00 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [216.228.9.89] by sunsite.dk (MessageWall 1.0.8) with SMTP; 1 Jan 2004 23:38:59 -0000 Received: by binome.blorf.net (Postfix, from userid 1000) id E47F07C90; Thu, 1 Jan 2004 15:38:56 -0800 (PST) Date: Thu, 1 Jan 2004 15:38:56 -0800 From: Wayne Davison To: Vincent Stemen Cc: zsh-users@sunsite.dk Subject: Re: Possible bug in zsh Message-ID: <20040101233856.GA13263@blorf.net> References: <20031229080222.GA75453@quark.localdomain> <20031229092122.GA23732@binome.blorf.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20031229092122.GA23732@binome.blorf.net> User-Agent: Mutt/1.5.4i On Mon, Dec 29, 2003 at 01:21:22AM -0800, Wayne Davison wrote: > false; if eval ''; then echo one; fi [...fails...] > true; if eval ''; then echo two; fi [...succeeds...] I'm hoping that someone more familiar with the exec internals will jump in here, but in the meantime, here's the change I made back on Monday to fix this bug: --- Src/builtin.c 13 Nov 2003 14:34:38 -0000 1.109 +++ Src/builtin.c 29 Dec 2003 09:50:52 -0000 @@ -4155,6 +4155,7 @@ errflag = 0; return 1; } + lastval = 0; execode(prog, 1, 0); if (errflag) { lastval = errflag; I'm not sure it's the best fix, though, as it might be better to change one of the lower functions down in the execode() calling chain instead of changing bin_eval(). It does fix the bug, though. ..wayne.. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27716 invoked from network); 2 Jan 2004 01:33:16 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 2 Jan 2004 01:33:16 -0000 Received: (qmail 20030 invoked by alias); 2 Jan 2004 01:32:31 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6970 Received: (qmail 19919 invoked from network); 2 Jan 2004 01:32:30 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 2 Jan 2004 01:32:30 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [130.95.128.56] by sunsite.dk (MessageWall 1.0.8) with SMTP; 2 Jan 2004 1:32:29 -0000 Received: from 127.0.0.1 (localhost [127.0.0.1]) by dummy.domain.name (Postfix) with SMTP id 44D553665B8 for ; Fri, 2 Jan 2004 09:32:28 +0800 (WST) Received: from gulag.gu.uwa.edu.au (gulag.guild.uwa.edu.au [130.95.100.5]) by asclepius.uwa.edu.au (Postfix) with ESMTP id 3BDA83664F2 for ; Fri, 2 Jan 2004 09:32:28 +0800 (WST) Received: from gulag.gu.uwa.edu.au (devenish@localhost [127.0.0.1]) by gulag.gu.uwa.edu.au (8.12.3/8.12.3/Debian-6.6) with ESMTP id i021WRoJ005068 for ; Fri, 2 Jan 2004 09:32:27 +0800 Received: (from devenish@localhost) by gulag.gu.uwa.edu.au (8.12.3/8.12.3/Debian-6.6) id i021WQOX005066 for zsh-users@sunsite.dk; Fri, 2 Jan 2004 09:32:26 +0800 Date: Fri, 2 Jan 2004 09:32:26 +0800 From: James Devenish To: zsh-users@sunsite.dk Subject: Re: Possible bug in zsh Message-ID: <20040102013226.GB4498@mail.guild.uwa.edu.au> Mail-Followup-To: zsh-users@sunsite.dk References: <20031229080222.GA75453@quark.localdomain> <20031229092122.GA23732@binome.blorf.net> <20040101233856.GA13263@blorf.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040101233856.GA13263@blorf.net> User-Agent: Mutt/1.3.28i In message <20040101233856.GA13263@blorf.net> on Thu, Jan 01, 2004 at 03:38:56PM -0800, Wayne Davison wrote: > On Mon, Dec 29, 2003 at 01:21:22AM -0800, Wayne Davison wrote: > > false; if eval ''; then echo one; fi [...fails...] > > true; if eval ''; then echo two; fi [...succeeds...] > > I'm hoping that someone more familiar with the exec internals will jump > in here, but in the meantime, here's the change I made back on Monday to > fix this bug: Is it really a bug? Doesn't ksh offer this as the preferred behaviour by default in the absence of the 'posix' option? But it seems like an oversight that zsh doesn't give you the ability to have the POSIX behaviour. Perhaps this is one of the featurebugs that makes zsh unsuitable as /bin/sh. Some zsh scripts might depend on zsh's current behaviour. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4666 invoked from network); 3 Jan 2004 23:09:47 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 3 Jan 2004 23:09:47 -0000 Received: (qmail 12358 invoked by alias); 3 Jan 2004 23:09:25 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6972 Received: (qmail 12317 invoked from network); 3 Jan 2004 23:09:25 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 3 Jan 2004 23:09:25 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [68.1.17.115] by sunsite.dk (MessageWall 1.0.8) with SMTP; 3 Jan 2004 23:9:24 -0000 Received: from quark.localdomain ([68.12.75.33]) by lakemtao06.cox.net (InterMail vM.5.01.06.05 201-253-122-130-105-20030824) with ESMTP id <20040103230924.WEAF24575.lakemtao06.cox.net@quark.localdomain>; Sat, 3 Jan 2004 18:09:24 -0500 Received: from quark.localdomain (localhost.localdomain [127.0.0.1]) by quark.localdomain (8.12.9/8.12.9) with ESMTP id i03N9WuO063792; Sat, 3 Jan 2004 17:09:32 -0600 (CST) (envelope-from vince@quark.localdomain) Received: (from vince@localhost) by quark.localdomain (8.12.9/8.12.9/Submit) id i03N9Vig063791; Sat, 3 Jan 2004 17:09:31 -0600 (CST) Date: Sat, 3 Jan 2004 17:09:31 -0600 From: Vincent Stemen To: Wayne Davison Cc: zsh-users@sunsite.dk Subject: Re: Possible bug in zsh Message-ID: <20040103230931.GA63684@quark.localdomain> References: <20031229080222.GA75453@quark.localdomain> <20031229092122.GA23732@binome.blorf.net> <20040101233856.GA13263@blorf.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040101233856.GA13263@blorf.net> User-Agent: Mutt/1.4.1i On Thu, Jan 01, 2004 at 03:38:56PM -0800, Wayne Davison wrote: > On Mon, Dec 29, 2003 at 01:21:22AM -0800, Wayne Davison wrote: > > false; if eval ''; then echo one; fi [...fails...] > > true; if eval ''; then echo two; fi [...succeeds...] > > I'm hoping that someone more familiar with the exec internals will jump > in here, but in the meantime, here's the change I made back on Monday to > fix this bug: > > --- Src/builtin.c 13 Nov 2003 14:34:38 -0000 1.109 > +++ Src/builtin.c 29 Dec 2003 09:50:52 -0000 > @@ -4155,6 +4155,7 @@ > errflag = 0; > return 1; > } > + lastval = 0; > execode(prog, 1, 0); > if (errflag) { > lastval = errflag; > > I'm not sure it's the best fix, though, as it might be better to change > one of the lower functions down in the execode() calling chain instead > of changing bin_eval(). It does fix the bug, though. > > ..wayne.. Thanks for the responses Wayne. I will archive this in case I need it in the future. For now, it looks like there are also other incompatibilities in running the init scripts (well, at least one so far) that also prevent using zsh as sh in FreeBSD. So, I think I will put that idea on hold for now and stick with the native /bin/sh. I temporarily modified the init script code which got around the eval problem and discovered that some of the scripts use "set -T" which is not implemented in zsh. The FreeBSD sh man page says this about it. -T trapsasync When waiting for a child, execute traps immediately. If this option is not set, traps are executed after the child exits, as specified in IEEE Std 1003.2 (``POSIX.2'') This nonstandard option is useful for putting guarding shells around children that block signals. The surrounding shell may kill the child or it may just return control to the tty and leave the child alone, like this: sh -T -c "trap 'exit 1' 2 ; some-blocking-program" Regards, Vincent -- Vincent Stemen Avoid the VeriSign/Network Solutions domain registration trap! http://www.InetAddresses.net