From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by melb.werple.net.au (8.7.5/8.7.3) with ESMTP id TAA14982 for ; Tue, 28 May 1996 19:35:52 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id FAA08280; Tue, 28 May 1996 05:19:12 -0400 (EDT) Resent-Date: Tue, 28 May 1996 05:19:12 -0400 (EDT) Message-Id: <199605280918.LAA10810@hydra.ifh.de> To: zsh-workers@math.gatech.edu (Zsh hackers list) Subject: $(nooutput) problem Date: Tue, 28 May 1996 11:18:09 +0200 From: Peter Stephenson Resent-Message-ID: <"67iB12.0.E12.FKign"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/1208 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu It seems care is needed: (1) if a command is not a simple one no arguments may be necessary, so that having no arguments in execcmd() is perfectly legal; (2) single word substitution needs to keeps its arguments, for example the variable assignment code expects something back from prefork(); (3) there's another bug/incompatibility (nearer the latter than the former) resulting from the failure to delete empty arguments: % ksh -c 'cmd=; $cmd print foo' foo % zsh -fc 'cmd=; $cmd print foo' zsh: permission denied: print (which is certainly not the right answer in any case). For these reasons I've fixed the problem by getting prefork() to junk empty nodes if and only if it is not doing single word substitution, and execcmd() to return if and only if it is a `simple' command with no arguments. *** Src/exec.c.empty Fri May 17 16:25:20 1996 --- Src/exec.c Tue May 28 10:35:36 1996 *************** *** 1200,1205 **** --- 1200,1208 ---- /* Do prefork substitutions */ prefork(args, (((type == CCASE) ? 4 : 0) | (assign ? 2 : isset(MAGICEQUALSUBST)))); + if (type == SIMPLE && empty(args)) + return; + /* Set up special parameter $_ */ zsfree(underscore); if (nonempty(args) && (underscore = ztrdup((char *) getdata(lastnode(args))))) *** Src/subst.c.empty Tue May 28 10:34:04 1996 --- Src/subst.c Tue May 28 10:41:15 1996 *************** *** 51,57 **** void prefork(LinkList list, int flags) { ! LinkNode node; for (node = firstnode(list); node; incnode(node)) { char *str, *str3; --- 51,57 ---- void prefork(LinkList list, int flags) { ! LinkNode node, next; for (node = firstnode(list); node; incnode(node)) { char *str, *str3; *************** *** 69,77 **** else if (!(node = stringsubst(list, node, flags & 4))) return; } ! for (node = firstnode(list); node; incnode(node)) { if (*(char *)getdata(node)) remnulargs(getdata(node)); if (unset(IGNOREBRACES) && !(flags & 4)) while (hasbraces(getdata(node))) xpandbraces(list, &node); --- 69,82 ---- else if (!(node = stringsubst(list, node, flags & 4))) return; } ! for (node = firstnode(list); node; node = next) { ! next = nextnode(node); if (*(char *)getdata(node)) remnulargs(getdata(node)); + else if (!(flags & 4)) { + uremnode(list, node); + continue; + } if (unset(IGNOREBRACES) && !(flags & 4)) while (hasbraces(getdata(node))) xpandbraces(list, &node); -- Peter Stephenson 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.