Date: Mon, 12 Aug 2002 09:00:07 -0700 (PDT) From: "Artem 'Zazoobr' Ignatjev" <timon@memphis.mephi.ru> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/41410: /bin/sh bug on expanding $? in here-documents Message-ID: <200208121600.g7CG070u050548@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/41410; it has been noted by GNATS. From: "Artem 'Zazoobr' Ignatjev" <timon@memphis.mephi.ru> To: freebsd-gnats-submit@FreeBSD.org, rse@engelschall.com Cc: Subject: Re: bin/41410: /bin/sh bug on expanding $? in here-documents Date: Mon, 12 Aug 2002 19:52:55 +0400 I've hacked around a bit, and found following code : eval.c:649: oexitstatus = exitstatus; eval.c:650: exitstatus = 0; then, in function expredir: eval.c:454: for (redir = n ; redir ; redir = redir->nfile.next) { eval.c:455: struct arglist fn; eval.c:456: fn.lastp = &fn.list; eval.c:457: oexitstatus = exitstatus; But once we're here, exitstatus is already 0 I've tried to remove offending line #650, and your script showed the same values three times. I've also modified it to check, whether it's required to explicitly set exitstatus to 0, testing "yes" for being "yes" each time after your attempt. Output is as shown: attempt 1: $?=1 $1=foo $2=bar $baz=quux attempt 1': $?=0 $1=foo $2=bar $baz=quux attempt 2: $?=1 $1=foo $2=bar $baz=quux attempt 2': $?=0 $1=foo $2=bar $baz=quux attempt 3: $?=1 $1=foo $2=bar $baz=quux attempt 3': $?=0 $1=foo $2=bar $baz=quux Here's my version of your script: begin 644 buggy.sh.gz M'XL(`!#65ST``^W8OT[#,!`&\-U/<6TB4880DI:_:JB$!`M#7X#%"2:I%,?! M=B2*>'B<0EL52AL&!M!71;T,]SM_E]%>+RR4%*&=256%1F>A*=Q#S"-*FSR? M'YF",2,L!0$]*D4IURSE+\E3TSRSMHNXM4+6EKR(!F8FZU*0R`KENC5E2M9< MSXRJ#ID5QM)<&.HE;6&+IOY21Y=T[T\2?^)*E/B1*W'BQZZTI[5__?6$K0,. M.DS8#!R[P)*7)15"B^!!98T4E?V:-..6QN.;Z2U;TGCO6:QM_Y28OO^MS]C1 M]-&Z"K%_X_<4&TL/:5!RG8O-I>DJH='=]8[=Z95R+>KEH%6*X?X0QU$\')V< MGIU?_/P-&!@8&!@8&!@8&!@8&!CX_^(MUR<=[B(ZW(C\T>\!#`P,#`P,#`P, 4#`P,#`S\RWAQ&?$&0[*9Y"LC```` ` end And here's the suggested patch: --- /usr/src/bin/sh/eval.c Thu Jul 5 04:41:14 2001 +++ /usr/src/bin/sh/eval.c Mon Aug 12 19:29:00 2002 @@ -647,7 +647,7 @@ varflag = 1; oexitstatus = exitstatus; - exitstatus = 0; +// exitstatus = 0; for (argp = cmd->ncmd.args ; argp ; argp = argp->narg.next) { char *p = argp->narg.text; if (varflag && is_name(*p)) { --- Patch ends here --- Sinceherely yours, Artem 'Zazoobr' Ignatjev. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200208121600.g7CG070u050548>