Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 05 Oct 2018 21:19:47 +0000
From:      bugzilla-noreply@freebsd.org
To:        standards@FreeBSD.org
Subject:   [Bug 231986] non-interactive sh should return 127 for command not found
Message-ID:  <bug-231986-99@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D231986

            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@FreeBSD.org
          Reporter: grahamyvr@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=20
#!/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
$=20

I think the final "2" should be "127" since it's a non-interactive shell.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-231986-99>