On 12/25/20 4:40 AM, Markus Elfring wrote:
Hello,

I am looking for another bit of clarification according to an implementation 
detail.

The manual is providing the following information.
https://git.savannah.gnu.org/cgit/bash.git/tree/doc/bash.1?id=76404c85d492c001f59f2644074333ffb7608532#n627

“…
        If  a command is terminated by the control operator &, the shell 
executes the command in the background in a subshell.  The shell does not wait for 
the command to finish, and the
        return status is 0.
…”


Thus I observe a behaviour like the following for a simple test with the
software “bash 5.0.18-3.1” according to a “program” which does not exist here.

elfring@Sonne:~> xy &
[1] 4063
xy: Befehl nicht gefunden
[1]+  Exit 127                xy

Yes, the child process exits with status 127, but $? is set to 0, as POSIX
requires. If you want the exit status of the child process, add `wait $!'
when you are ready to use the status, which will set $? to 127.

Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/

Reply via email to