command -v bug with dash-0.5.11.1

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

 



Hi,

Using dash-0.5.11.1 I found that command -v sometimes will return 0 for
a non-executable file.

The posix spec says for 'command -v':

"Utilities, regular built-in utilities, command_names including a
<slash> character, and any implementation-defined functions that are
found using the PATH variable"

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

And under PATH it says:

"in PATH. The list shall be searched from beginning to end, applying
the filename to each prefix, until an executable file with the
specified name and appropriate execution permissions is found."

https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html

In the attached test script it will return:

$ dash ./test.sh 
test/testfile
0

Where 'testfile' is an empty file with the permissions of 0644 and not
executable. I think this is a bug where 'command -v' should return 1
and not find a file?

I've noticed that bash also shares this behavior, but not bash when
executed as 'sh' or other shells like mksh, yash and zsh.

Attachment: test.sh
Description: application/shellscript


[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux