diff mbox series

[5/5] checkbashisms: Disable 'type' check

Message ID 20210902115837.2199-1-pvorel@suse.cz
State Rejected
Headers show
Series None | expand

Commit Message

Petr Vorel Sept. 2, 2021, 11:58 a.m. UTC
'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.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
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(-)

Comments

Cyril Hrubis Sept. 2, 2021, 1:33 p.m. UTC | #1
Hi!
Looks good.

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Petr Vorel Sept. 3, 2021, 10:30 a.m. UTC | #2
Hi Cyril,

> Hi!
> Looks good.

> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

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
diff mbox series

Patch

diff --git a/scripts/checkbashisms.pl b/scripts/checkbashisms.pl
index ba417c993..6dc762cb7 100755
--- a/scripts/checkbashisms.pl
+++ b/scripts/checkbashisms.pl
@@ -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]>,