bug-bash
[Top][All Lists]
Advanced

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

Re: Re: ‘command … &’ creates subshell


From: Robert Elz
Subject: Re: Re: ‘command … &’ creates subshell
Date: Wed, 01 Jul 2020 22:05:17 +0700

    Date:        Wed, 1 Jul 2020 07:54:05 -0400
    From:        Eli Schwartz <eschwartz@archlinux.org>
    Message-ID:  <511886e8-2262-39ee-2a01-7d284e981cb1@archlinux.org>

  | Indeed -- that's why I specifically used the bashism $(type -P ...) as
  | type -P forces the printing of an external file executable.

Yes, saw that, that method would work, I was commenting only upon
the use of "command" with the intent of executing a file.

  | Regarding use of env, I presume you're referring to the busybox behavior
  | here,

Or anything similar.   env is an entirely reasonable command to build in,
it is doing very shell like operations, so any shell (including bash as
a loadable builtin I'd assume, but I don't do that kind of think to bash
so I don't know for sure) could build in env, and as soon as it is built
in it can run other built in commands (nothing in its spec forbids any of
that).

  | so shouldn't env be safe to use as such, if you know: [...]

If you know all that, then you also know what is builtin, and that
if you say just "ls" or "awk" the external command will be run, as
there is no other possibility ("will be" assuming they're found in
the current PATH of course).   Similarly you probably know that
/bin/cat works.

The whole point of trying to find a technique like was hoped for
using command, and others have used env for, and still others,
(exec command) (none of which are guaranteed to work) is so that
the script will work with different shells and in different
environments.

kre




reply via email to

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