Package: debian-policy
Version: 3.6.1.1
Severity: minor
Section 9.3.3.2 gives this as an example of how to check for the
availability of invoke-rc.d:
> if command -v invoke-rc.d >/dev/null 2>&1; then
1. It would be helpful to mention that "command -v" is not POSIX and
that therefore, to be consistent with section 10.4, this example
should only be followed in scripts headed with "#!/bin/bash".
If #218530 is ever implemented then this restriction can be
dropped.
2. "command -v" in bash 3.0-5 sometimes prints pathnames of files
on the PATH that aren't executable. To work around this, the
example could be changed to something like this:
if CMD="$(command -v invoke-rc.d 2>/dev/null)" && [ -x "$CMD" ] ; then
Discussion
----------
I actually think that issue #2 is a bug in bash. Consider the following
sequence of commands which illustrate that "command -v foo" prints
the name of the first executable file "foo" it finds on the PATH,
failing which it prints the first non-executable file "foo" it finds
on the PATH. What sense does that make? If people agree then I'll
file a bug report against bash.
[EMAIL PROTECTED]:~$ echo $PATH
/home/jdthood/bin:/usr/local/bin:/bin:/usr/bin:/usr/bin/X11:/usr/games
[EMAIL PROTECTED]:~$ which foo
[EMAIL PROTECTED]:~$ command -v foo
bash: command: foo: not found
[EMAIL PROTECTED]:~$ touch /home/jdthood/bin/foo
[EMAIL PROTECTED]:~$ ls -l /home/jdthood/bin/foo
-rw-r--r-- 1 jdthood jdthood 0 2005-01-18 10:40 /home/jdthood/bin/foo
[EMAIL PROTECTED]:~$ which foo
[EMAIL PROTECTED]:~$ command -v foo
/home/jdthood/bin/foo
[EMAIL PROTECTED]:~$ sudo touch /usr/local/bin/foo
[EMAIL PROTECTED]:~$ which foo
[EMAIL PROTECTED]:~$ command -v foo
/home/jdthood/bin/foo
[EMAIL PROTECTED]:~$ ls -l /usr/local/bin/foo
-rw-r--r-- 1 root staff 0 2005-01-18 10:41 /usr/local/bin/foo
[EMAIL PROTECTED]:~$ sudo chmod ugo+x /usr/local/bin/foo
[EMAIL PROTECTED]:~$ ls -l /usr/local/bin/foo
-rwxr-xr-x 1 root staff 0 2005-01-18 10:41 /usr/local/bin/foo
[EMAIL PROTECTED]:~$ which foo
/usr/local/bin/foo
[EMAIL PROTECTED]:~$ command -v foo
/usr/local/bin/foo
-- System Information:
Debian Release: 3.1
APT prefers testing
APT policy: (500, 'testing'), (50, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.9
Locale: [EMAIL PROTECTED], [EMAIL PROTECTED] (charmap=ISO-8859-15)
-- no debconf information
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]