dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* command lookup and POSIX
@ 2014-03-07 19:43 Jason Miller
  2014-03-07 21:53 ` Eric Blake
  2014-03-08 17:22 ` Paul Gilmartin
  0 siblings, 2 replies; 5+ messages in thread
From: Jason Miller @ 2014-03-07 19:43 UTC (permalink / raw)
  To: dash

Reading this:

http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_09_01_01

Any built-in other than the special built-ins, or listed in the table
there should not be run unless it is present in the PATH.

dash however doesn't follow that:

PS1="% " dash

    % PATH=
    % /usr/bin/which [
    /usr/bin/which: no [ in ()
    % [ -x f ]
    % 

Of course I can't find a single shell that follows this, even when
enabling its respective strict POSIX mode.  I'm guessing it was added to
prevent changes in behaviors of existing scripts as shells add more
builtins.

However, changing dash to comply also seems of dubious value since there
are many shell scripts out there that depend on common built-ins not
listed in POSIX.

However DASH claims POSIX compliance so I thought I would at least
mention it now that I found it.

-Jason

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: command lookup and POSIX
  2014-03-07 19:43 command lookup and POSIX Jason Miller
@ 2014-03-07 21:53 ` Eric Blake
  2014-03-07 22:48   ` Jason Miller
  2014-03-08 17:22 ` Paul Gilmartin
  1 sibling, 1 reply; 5+ messages in thread
From: Eric Blake @ 2014-03-07 21:53 UTC (permalink / raw)
  To: Jason Miller, dash

[-- Attachment #1: Type: text/plain, Size: 779 bytes --]

On 03/07/2014 12:43 PM, Jason Miller wrote:
> Reading this:
> 
> http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_09_01_01
> 
> Any built-in other than the special built-ins, or listed in the table
> there should not be run unless it is present in the PATH.
> 
> dash however doesn't follow that:
> 
> PS1="% " dash
> 
>     % PATH=

Stop right there.

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08

"If PATH is unset or is set to null, the path search is
implementation-defined."

Therefore, you have triggered implementation-defined behavior, rather
than exposing a bug in dash.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: command lookup and POSIX
  2014-03-07 21:53 ` Eric Blake
@ 2014-03-07 22:48   ` Jason Miller
  2014-03-07 23:44     ` Eric Blake
  0 siblings, 1 reply; 5+ messages in thread
From: Jason Miller @ 2014-03-07 22:48 UTC (permalink / raw)
  To: Eric Blake; +Cc: dash

On 14:53 Fri 07 Mar     , Eric Blake wrote:
> On 03/07/2014 12:43 PM, Jason Miller wrote:
> > Reading this:
> > 
> > http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_09_01_01
> > 
> > Any built-in other than the special built-ins, or listed in the table
> > there should not be run unless it is present in the PATH.
> > 
> > dash however doesn't follow that:
> > 
> > PS1="% " dash
> > 
> >     % PATH=
> 
> Stop right there.
> 
> http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08
> 
> "If PATH is unset or is set to null, the path search is
> implementation-defined."
> 
> Therefore, you have triggered implementation-defined behavior, rather
> than exposing a bug in dash.
Okay same question with PATH=/foo (dash's behavior is the same)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: command lookup and POSIX
  2014-03-07 22:48   ` Jason Miller
@ 2014-03-07 23:44     ` Eric Blake
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Blake @ 2014-03-07 23:44 UTC (permalink / raw)
  To: Jason Miller; +Cc: dash

[-- Attachment #1: Type: text/plain, Size: 1590 bytes --]

On 03/07/2014 03:48 PM, Jason Miller wrote:
> On 14:53 Fri 07 Mar     , Eric Blake wrote:
>> On 03/07/2014 12:43 PM, Jason Miller wrote:
>>> Reading this:
>>>
>>> http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_09_01_01

By the way, this is the Issue 6 version of POSIX (2001, updated via
technical corrigendum 1 and 2 through 2004).  You want to be looking at
Issue 7 (2008, with technical corrigendum 1 in 2013).

>>>
>>> Any built-in other than the special built-ins, or listed in the table
>>> there should not be run unless it is present in the PATH.
>>>
>>> dash however doesn't follow that:
>>>
>>> PS1="% " dash
>>>
>>>     % PATH=
>>
>> Stop right there.
>>
>> http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08
>>
>> "If PATH is unset or is set to null, the path search is
>> implementation-defined."
>>
>> Therefore, you have triggered implementation-defined behavior, rather
>> than exposing a bug in dash.
> Okay same question with PATH=/foo (dash's behavior is the same)

Still a problem in your script - POSIX says that you have a
non-compliant environment if you do certain things to PATH, at which
point dash can do whatever it wants.  Basically, if PATH ever lacks any
directories in 'getconf PATH', you have left the realm of POSIX
compliance.  See also the application usage for command:

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: command lookup and POSIX
  2014-03-07 19:43 command lookup and POSIX Jason Miller
  2014-03-07 21:53 ` Eric Blake
@ 2014-03-08 17:22 ` Paul Gilmartin
  1 sibling, 0 replies; 5+ messages in thread
From: Paul Gilmartin @ 2014-03-08 17:22 UTC (permalink / raw)
  To: Jason Miller

On 2014-03-07, at 12:43, Jason Miller wrote:

> Reading this:
> 
> http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_09_01_01
> 
> Any built-in other than the special built-ins, or listed in the table
> there should not be run unless it is present in the PATH.
>    ...
> Of course I can't find a single shell that follows this, even when
> enabling its respective strict POSIX mode.
> 
z/OS: http://pic.dhe.ibm.com/infocenter/zos/v2r1/topic/com.ibm.zos.v2r1.bpxa500/toc.htm

user@HOST: uname -a                                                                                                                    
OS/390 MVS3 23.00 03 2818
user@HOST: type echo                                                                                                                  
echo is a built-in command
user@HOST: PATH=/bin echo Hello                                                                                                        
Hello
user@HOST: PATH=/foo echo Hello                                                                                                        
echo: FSUM7351 not found

> ... I'm guessing it was added to
> prevent changes in behaviors of existing scripts as shells add more
> builtins.
> 
I would agree.

-- gil


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-03-08 17:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-07 19:43 command lookup and POSIX Jason Miller
2014-03-07 21:53 ` Eric Blake
2014-03-07 22:48   ` Jason Miller
2014-03-07 23:44     ` Eric Blake
2014-03-08 17:22 ` Paul Gilmartin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).