From owner-freebsd-hackers Thu May 1 08:08:04 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id IAA28471 for hackers-outgoing; Thu, 1 May 1997 08:08:04 -0700 (PDT) Received: from punt-1.mail.demon.net (relay-7.mail.demon.net [194.217.242.9]) by hub.freebsd.org (8.8.5/8.8.5) with SMTP id IAA28466 for ; Thu, 1 May 1997 08:08:01 -0700 (PDT) Received: from erlenstar.demon.co.uk ([194.222.144.22]) by punt-1.mail.demon.net id aa0610296; 1 May 97 15:46 BST Received: (from andrew@localhost) by erlenstar.demon.co.uk (8.8.5/8.8.5) id PAA05199; Thu, 1 May 1997 15:45:41 +0100 (BST) To: chet@po.cwru.edu Cc: hackers@freebsd.org Subject: Re: /bin/sh -c and ENV References: <9705011332.AA06946.SM@odin.INS.CWRU.Edu> From: Andrew Gierth In-Reply-To: Chet Ramey's message of Thu, 1 May 1997 09:32:30 -0400 X-Mayan-Date: Long count = 12.19.4.2.5; tzolkin = 9 Chicchan; haab = 3 Uo X-Attribution: AG Date: 01 May 1997 15:45:41 +0100 Message-ID: <87lo5z2qui.fsf@erlenstar.demon.co.uk> Lines: 70 X-Mailer: Gnus v5.3/Emacs 19.34 Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk >>>>> "Chet" == Chet Ramey writes: Chet> It's a bug. A post-publication POSIX.2 interpretation made it clear Chet> that ENV should be executed only for interactive shells. Should ENV be disabled for *all* non-interactive shells, or only for -c? I ask, because I just confirmed the results I recalled from testing this on HP-UX 10.10 (the first Unix flavour I encountered where /bin/sh was a Posix shell rather than a Bourne shell), and on that version at least, if you do "sh scriptname" (or invoke a #!-type script) then it still sources the ENV file. Basically, given the following script: ---8<-------- #!/bin/sh [ -z "$1" ] || { echo "Recursive test completed"; exit 0; } ENV=$HOME/env_test export ENV echo "echo ENV was executed" >$ENV echo "Testing -c:" /bin/sh -c "echo Test completed" echo "Testing sh scriptname" /bin/sh $0 recurse echo "Testing #!" $0 recurse exit ---8<-------- the output on FreeBSD is: /u/andrew $ ./foo Testing -c: ENV was executed Test completed Testing sh scriptname ENV was executed Recursive test completed Testing #! ENV was executed Recursive test completed /u/andrew $ whereas the output on HP-UX 10.10 is: /u/andrew $ ./foo Testing -c: Test completed Testing sh scriptname ENV was executed Recursive test completed Testing #! ENV was executed Recursive test completed /u/andrew $ Now I'm quite prepared to believe that these are *both* wrong in some respect, but I'd like to know what the intended *correct* behaviour is. -- Andrew. (FAQ-maintainer for comp.unix.programmer)