Skip to contentSkip to conversation

checkbashisms: Disable 'type' check

PATCH New Petr Vorel 2 participants 3 messages Sep 2, 2021 – Sep 3, 2021

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

PATCH 5/5 checkbashisms: Disable 'type' check

'type' is part of POSIX, but as part of the X/Open Systems Interfaces option (XSI). The checkbashisms man page explicitly says:

Note that the definition of a bashism in this context roughly equates to "a shell feature that is not required to be supported by POSIX"; this means that some issues flagged may be permitted under optional sections of POSIX, such as XSI or User Portability.

'type' is flagged because it is an optional feature. But because it's supported by all common shells (i.e. > bash, zsh, dash, busybox sh, mksh) we use it even in the library => disable the check.

---
Hi,

follow up to patchset "checkbashisms.pl in make check + fixed docs" [1].

Kind regards,
Petr

[1] https://patchwork.ozlabs.org/project/ltp/list/?series=260711

 scripts/checkbashisms.pl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/checkbashisms.pl +2 -1
index ba417c993..6dc762cb7 100755
@@ -675,7 +675,8 @@ sub init_hashes {
         $LEADIN . qr'shopt(\s|\Z)'       => q<shopt>,
         $LEADIN . qr'suspend\s'          => q<suspend>,
         $LEADIN . qr'time\s'             => q<time>,
-        $LEADIN . qr'type\s'             => q<type>,
+        # LTP supports type
+        # $LEADIN . qr'type\s'             => q<type>,
         $LEADIN . qr'typeset\s'          => q<typeset>,
         $LEADIN . qr'ulimit(\s|\Z)'      => q<ulimit>,
         $LEADIN . qr'set\s+-[BHT]+'      => q<set -[BHT]>,
Signature · 1 line
2.33.0
author
#2 lore raw

PATCH 5/5 checkbashisms: Disable 'type' check

Hi Cyril,

Quoted 4 lines

Hi!
Looks good.

Looks like 'command -v' which is POSIX works (tested in bash, dash, busybox sh and android shell), thus I suggest to drop this patch and use 'command -v' instead of 'type'.

$ foo(){ echo "in foo";}
$ command -v foo
foo

Kind regards,
Petr