[Top][All Lists]

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

Re: ‘command … &’ creates subshell

From: Robert Elz
Subject: Re: ‘command … &’ creates subshell
Date: Thu, 02 Jul 2020 04:36:33 +0700

    Date:        Wed, 01 Jul 2020 20:00:23 +0200
    From:        Andreas Schwab <schwab@linux-m68k.org>
    Message-ID:  <871rlvcdzc.fsf@igel.home>

  | But it also says:
  |     If command is not found, the exit status shall be 127. If command is
  |     found, but it is not an executable utility, the exit status shall be
  |     126.

If the command is built-in, it can hardly not be found, so the first
half of that doesn't apply.  All that's left is "executable utility".
That isn't actually defined anywhere, but "utility" is, and while it
excludes the special built-ins, everything else that can be run as
a command counts, including those that only make sense when built in
(like say, command).

jinx$ echo $$
jinx$ exec command echo hello
bash: exec: command: not found
jinx$ echo $$
jinx$ exit

NetBSD (deliberately, as it is stupid) ignores the requirement that
all non-special builtns be also provided as commands in the filesystem,
if we had a /usr/bin/command (or something) I assume bash would have
run it (even though XCU 1.d says that "command" is one of the
magic builtins which should be run as the built-in without bothering
with a PATH search first).

Having said all this, do be aware that this is all relevant to the
current POSIX standard, the next version [probably] changes the wording to:

   If exec is specified with a utility operand, the shell shall execute
   a non-built-in utility as described in Section with utility
   as the command name [...]

It will also require interactive top level shells not to exit on
exec error,

[None of this is set in stone yet, and changes might still be made].

The first of those changes matches what most shells do (as I said earlier),
the second will require changes in most shells, which currently do exit
as the current standard requires.,


reply via email to

[Prev in Thread] Current Thread [Next in Thread]