bug-bash
[Top][All Lists]
Advanced

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

Re: bash should not alter PATH with 'command -p'


From: Stephane Chazelas
Subject: Re: bash should not alter PATH with 'command -p'
Date: Tue, 2 Jun 2015 16:22:24 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

2015-05-28 13:59:01 -0600, sdowdy@rap.ucar.edu:
[...]
> 'command -p' 
>     Ref:http://pubs.opengroup.org/onlinepubs/009696699/utilities/command.html
> 
>     "... -p Perform the command search using a default value for PATH that is 
> guaranteed to find all of the standard utilities. ..."
> 
>     The way i read that is:
>         "search for a command only in a default PATH location, then invoke it 
> (not altering user environment in the process)"
>     The way 'bash' seems to be looking at that is:
>         "set the user's PATH to a default value, then invoke"
[...]

On the other hand, you'd like:

command -p env foo=bar sh

To invoke the POSIX sh (as opposed to the one in /usr/local/jdk
or elsewhere).

One could try:

command -p env foo=bar command -p sh

That won't work in any of the GNU-based systems I know as they
don't include a "command" command on the filesystem.

And even then, that "filesystem command" would not necessarily
be the POSIX one. That "command -p" concept has a chicken and
egg issue.

In any case, the bash behaviour if one wants it, can be emulated
with:

env "PATH=$(getconf PATH)" cmd...

(again env and getconf many not be guaranteed to be the ones you
like...)

So, it's probably better for bash to do the same thing as what
other shells do.

-- 
Stephane




reply via email to

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