NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/55820: sh sources the ENV file for non interactive shells



>Number:         55820
>Category:       bin
>Synopsis:       sh sources the ENV file for non interactive shells
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 23 18:40:00 +0000 2020
>Originator:     Andreas Scheme
>Release:        9.1
>Organization:
>Environment:
NetBSD NetBSD.local 9.1 NetBSD 9.1 (GENERIC) #0: Sun Oct 18 19:24:30 UTC 2020  mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/amd64/compile/GENERIC amd64
>Description:
NetBSD sh and ksh have a unique behavior in respect of ENV compared to shells I've tested (several Bourne like shells on OpenBSD, FreeBSD, Linux, Solaris). More over, this behavior is not conforming to POSIX.

- the file designated by ENV is source for non-interactive shell, it shouldn't according to POSIX

- when executing an "exit" command in that file, the shell exit; other shells I've tested just stop processing the file and continue their normal execution. I don't know if POSIX specify this behavior. I've met it in no other shell.
>How-To-Repeat:
Here is an execution log

$ export ENV=$(pwd)/env
$ cat env
echo Not OK
exit
$ sh -c "echo OK"
Not OK
$ 

I'd have expected to get "OK" instead. Here is a second execution log

$ export ENV=$(pwd)/env
$ cat env
echo OK1
exit
echo Not OK
$ sh -ic "echo OK2"
OK1
$ 

I'd have expected to get 

OK1
OK2

instead.
>Fix:



Home | Main Index | Thread Index | Old Index