[Bug 231986] non-interactive sh should return 127 for command not found
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Fri Oct 5 21:19:50 UTC 2018
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=231986
Bug ID: 231986
Summary: non-interactive sh should return 127 for command not
found
Product: Base System
Version: 11.2-RELEASE
Hardware: Any
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: standards
Assignee: standards at FreeBSD.org
Reporter: grahamyvr at gmail.com
According to the POSIX spec
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sh.html:
EXIT STATUS
...
127
A specified command_file could not be found by a non-interactive shell.
However, sh(1) on FreeBSD 11.2-RELEASE-p4 sometimes returns 2. Consider:
$ cat run-fake-command.sh
#!/bin/sh
fake-command
$ ./run-fake-command.sh ; echo $?
./run-fake-command.sh: fake-command: not found
127
$ fake-command ; echo $?
-sh: fake-command: not found
127
$ sh fake-command ; echo $?
sh: cannot open fake-command: No such file or directory
2
$
I think the final "2" should be "127" since it's a non-interactive shell.
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the freebsd-standards
mailing list