#733511 checkbashisms: wrongly reports 'command -v' as a bashism

Package:
devscripts
Source:
devscripts
Description:
scripts to make the life of a Debian Package maintainer easier
Submitter:
Aurelien Jarno
Date:
2015-11-11 00:51:07 UTC
Severity:
normal
#733511#5
Date:
2013-12-29 15:35:52 UTC
From:
To:
checkbashisms consider that command can only take the -p option:

| $ echo -e '#!/bin/sh\ncommand -v ls' > posix.sh
| $ checkbashisms posix.sh
| possible bashism in posix.sh line 2 ('command' with option other than -p):
| command -v ls
| $

This is not true according to POSIX specification [1], -v and -V shall
also be accepted. They are accepted in practice by both dash and bash.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html
--- /etc/devscripts.conf ---

#733511#10
Date:
2013-12-29 17:01:02 UTC
From:
To:
This is a somewhat interesting case. The link above is for the Base
Specifications Issue 7, which is IEEE 1003.1 2013. Policy specifically
refers to IEEE 1003.1 2004, aka Issue 6, where -v and -V are listed as
User Portability Utilities extensions and therefore not required to be
supported.

Regards,

Adam

#733511#17
Date:
2015-11-11 00:48:34 UTC
From:
To:
POSIX permits the -v/-V options:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html
command [-p][-v|-V] command_name
---
 scripts/checkbashisms.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkbashisms.pl b/scripts/checkbashisms.pl
index 045328c..fe64a6b 100755
--- a/scripts/checkbashisms.pl
+++ b/scripts/checkbashisms.pl
@@ -644,7 +644,7 @@ sub init_hashes {
 	qr';;?&' =>  q<;;& and ;& special case operators>,
 	$LEADIN . qr'jobs\s' =>  q<jobs>,
 #	$LEADIN . qr'jobs\s+-[^lp]\s' =>  q<'jobs' with option other than -l or -p>,
-	$LEADIN . qr'command\s+-[^p]\s' =>  q<'command' with option other than -p>,
+	$LEADIN . qr'command\s+-[^pvV]\s' =>  q<'command' with option other than -p/-v/-V>,
 	$LEADIN . qr'setvar\s' =>  q<setvar 'foo' 'bar' should be eval 'foo="'"$bar"'"'>,
 	$LEADIN . qr'trap\s+["\']?.*["\']?\s+.*(?:ERR|DEBUG|RETURN)' => q<trap with ERR|DEBUG|RETURN>,
 	$LEADIN . qr'(?:exit|return)\s+-\d' => q<exit|return with negative status code>,