From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4068 invoked from network); 11 Dec 1998 13:30:19 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 11 Dec 1998 13:30:19 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id IAA08382; Fri, 11 Dec 1998 08:29:07 -0500 (EST) Resent-Date: Fri, 11 Dec 1998 08:29:07 -0500 (EST) From: "Andrej Borsenkow" To: "Peter Stephenson" , Subject: RE: PATCH: 3.1.5: eval with exported vars Date: Fri, 11 Dec 1998 16:27:50 +0300 Message-ID: <001b01be250a$0cd92290$21c9ca95@mowp.siemens.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook 8.5, Build 4.71.2173.0 In-Reply-To: <9812111245.AA42577@ibmth.df.unipi.it> Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.00.0810.800 Resent-Message-ID: <"WWjU02.0.s22.ZuHSs"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/4752 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu > > "Andrej Borsenkow" wrote: > > But as I understand, your patch blindly exports variable for > every builtin? > > No, just eval, which is a peculiar case because you really don't know > what it's going to do. Sorry. But I don't think this is needed. Currently it behaves exactly as it should. bor@itsrm2:~smbsrc/source%> FOO=x eval sh -c 'echo $FOO' bor@itsrm2:~smbsrc/source%> FOO=x eval 'sh -c echo $FOO' Both are correct as you explained. The string after -c is just "echo" It is funny, but so is it. bor@itsrm2:~smbsrc/source%> FOO=x eval sh -c "echo $FOO" Correct. $FOO is expanded when the whole is first read. bor@itsrm2:~smbsrc/source%> FOO=x eval 'sh -c "echo $FOO"' x Correct. eval gets 'sh -c "$FOO"', expands $FOO to x, so it amounts to sh -c 'echo x'. bor@itsrm2:~smbsrc/source%> FOO=x eval 'sh -c "echo \$FOO"' Correct. It expands to sh -c 'echo $FOO' and FOO is _not_ exported (and should not). bor@itsrm2:~smbsrc/source%> FOO=x eval 'FOO=bar sh -c "echo \$FOO"' bar If you really want to export something to command excuted in eval. Why is it wrong. It is clean and consistent. The workaround I gave (assignment after the > eval) is really the best way of doing it. You can certainly argue > it's not right to have eval as a special case, but I'd say exporting > it rather than just setting it is the safest here. > Why? See above - you always can export it if needed. > > This is supposed to depend on the setting of POSIXBUILTINS. 'course you are right. > > Possibly the patch I sent should have a !isset(POSIXBUILTINS) wrapper? > Possibly, we don't need the patch at all? /andrej