From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1170 invoked from network); 5 Jul 1999 15:10:43 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 5 Jul 1999 15:10:43 -0000 Received: (qmail 23452 invoked by alias); 5 Jul 1999 15:10:22 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6982 Received: (qmail 23445 invoked from network); 5 Jul 1999 15:10:22 -0000 Message-Id: <9907051441.AA32475@ibmth.df.unipi.it> To: zsh-workers@sunsite.auc.dk (Zsh hackers list) Subject: PATCH: pws-25: parameter assignment with redirection Date: Mon, 05 Jul 1999 16:41:41 +0200 From: Peter Stephenson This foo=bar >&/dev/null is interpreted as a redirection which uses $NULLCMD to write to /dev/null. I would interpret it as a parameter assigment with the output redirected so that error messages about bad patterns and so forth don't appear. This patch does that. --- Src/exec.c.av Mon Jul 5 13:16:12 1999 +++ Src/exec.c Mon Jul 5 16:38:12 1999 @@ -1532,6 +1532,9 @@ /* Was this "exec < foobar"? */ nullexec = 1; break; + } else if (vars && nonempty(vars)) { + nullexec = 2; + break; } else if (!nullcmd || !*nullcmd || (cflags & BINF_PREFIX)) { zerr("redirection with no command", NULL, 0); @@ -1871,7 +1874,8 @@ addfd(forked, save, mfds, fn->fd1, fil, 0); /* If this is 'exec < file', read from stdin, * * not terminal, unless `file' is a terminal. */ - if (nullexec && fn->fd1 == 0 && isset(SHINSTDIN) && interact) + if (nullexec == 1 && fn->fd1 == 0 && + isset(SHINSTDIN) && interact) init_io(); break; case CLOSE: @@ -1931,17 +1935,28 @@ closemn(mfds, i); if (nullexec) { - for (i = 0; i < 10; i++) - if (save[i] != -2) - zclose(save[i]); + if (nullexec == 1) { + /* + * If nullexec is 1 we specifically *don't* restore the original + * fd's before returning. + */ + for (i = 0; i < 10; i++) + if (save[i] != -2) + zclose(save[i]); + return; + } /* - * Here we specifically *don't* restore the original fd's - * before returning. + * If nullexec is 2, we have variables to add with the redirections + * in place. */ - return; - } - - if (isset(EXECOPT) && !errflag) { + if (vars) + addvars(vars, 0); + lastval = errflag ? errflag : cmdoutval; + if (isset(XTRACE)) { + fputc('\n', stderr); + fflush(stderr); + } + } else if (isset(EXECOPT) && !errflag) { /* * We delay the entersubsh() to here when we are exec'ing * the current shell (including a fake exec to run a builtin then -- Peter Stephenson Tel: +39 050 844536 WWW: http://www.ifh.de/~pws/ Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy