zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ifh.de>
To: zsh-workers@math.gatech.edu (Zsh hackers list)
Subject: Redirection bug fix
Date: Thu, 11 Jul 1996 14:51:40 +0200	[thread overview]
Message-ID: <199607111251.OAA04038@hydra.ifh.de> (raw)
In-Reply-To: "pws@ifh.de"'s message of "Thu, 11 Jul 1996 10:11:43 MET." <199607110811.KAA16695@hydra.ifh.de>

I wrote:
> huyle@chop.ugcs.caltech.edu reported a bug that:
> > pride% while echo crap >/dev/null; do done
> > ^C
> > pride% echo yes
> >                       <- nothing.  stdout has disappeared.
>
> Help

Actually, it's horribly obvious.  When errflag is set after a return
from addvars(), the shell thinks it was because the addvars() failed
and returns.  However, there was no code there to restore the fd's.
(The first patch was a note to me in case I got too zealous.)

Although it's not necessary here, it might prevent further bugs to
change the `if (unset(NOEXEC)) {' test in execcmd() to 
`if (unset(NOEXEC) && !errflag) {', i.e. if there was an interrupt and
errflag was set, don't try to execute anything at all.  This can't be
wrong and may save some time as well as later blood and tears.

*** Src/exec.c.redir	Wed Jul 10 15:48:17 1996
--- Src/exec.c	Thu Jul 11 14:41:32 1996
***************
*** 1554,1559 ****
--- 1554,1563 ----
  	for (i = 0; i < 10; i++)
  	    if (save[i] != -2)
  		zclose(save[i]);
+ 	/*
+ 	 * Here we specifically *don't* restore the original fd's
+ 	 * before returning.
+ 	 */
  	return;
      }
  
***************
*** 1583,1588 ****
--- 1587,1593 ----
  		if (errflag) {
  		    restore_params(restorelist, removelist);
  		    lastval = 1;
+ 		    fixfds(save);
  		    return;
  		}
  	    }
***************
*** 1653,1658 ****
--- 1658,1664 ----
  		addvars(cmd->vars, 1);
  		if (errflag) {
  		    lastval = 1;
+ 		    fixfds(save);
  		    return;
  		}
  	    }



-- 
Peter Stephenson <pws@ifh.de>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77330
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.



      reply	other threads:[~1996-07-11 13:02 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-07-06 22:59 Remaining zsh3.0-pre2 bugs Huy Le
1996-07-07  5:29 ` Bart Schaefer
1996-07-07  5:53 ` Bart Schaefer
1996-07-07  7:07   ` Bart Schaefer
1996-07-07  6:08 ` Bart Schaefer
1996-07-07  9:06   ` Zefram
1996-07-08  0:48 ` Zoltan Hidvegi
1996-07-08  4:22   ` Bart Schaefer
1996-07-08  6:21     ` Bart Schaefer
1996-07-08  7:57       ` Zefram
1996-07-08  8:48         ` Bart Schaefer
1996-07-09  1:32           ` Zoltan Hidvegi
1996-07-09  9:08             ` Bart Schaefer
1996-07-09 14:06               ` Zoltan Hidvegi
1996-07-10 19:11                 ` Bart Schaefer
1996-07-10 19:48                   ` Zoltan Hidvegi
1996-07-11  0:04                     ` Bart Schaefer
1996-07-11 12:16                       ` Zoltan Hidvegi
1996-07-11 16:45                         ` Bart Schaefer
1996-07-08 14:28     ` Zoltan Hidvegi
1996-07-08  6:38   ` Bart Schaefer
1996-07-11  8:11 ` Peter Stephenson
1996-07-11 12:51   ` 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=199607111251.OAA04038@hydra.ifh.de \
    --to=pws@ifh.de \
    --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).