Date: 01 May 1997 15:45:41 +0100 From: Andrew Gierth <andrew@erlenstar.demon.co.uk> To: chet@po.cwru.edu Cc: hackers@freebsd.org Subject: Re: /bin/sh -c and ENV Message-ID: <87lo5z2qui.fsf@erlenstar.demon.co.uk> In-Reply-To: Chet Ramey's message of Thu, 1 May 1997 09:32:30 -0400 References: <9705011332.AA06946.SM@odin.INS.CWRU.Edu>
next in thread | previous in thread | raw e-mail | index | archive | help
>>>>> "Chet" == Chet Ramey <chet@odin.ins.cwru.edu> 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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?87lo5z2qui.fsf>
