bashate: skip non sh/bash files

Bug #1712395 reported by Austin English
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
bash8
New
Undecided
Unassigned

Bug Description

Bashate currently tries to scan non shell scripts if passed in. It would be nice to bail out and warn the user properly. I.e., compare shellcheck and bashate, on a perl script:

austin@austin2:~$ file foo.pl
foo.pl: Perl script text executable

austin@austin2:~$ head -n 1 foo.pl
#!/usr/bin/env perl

austin@austin2:~$ shellcheck foo.pl

In foo.pl line 1:
#!/usr/bin/env perl
^-- SC1071: ShellCheck only supports sh/bash/dash/ksh scripts. Sorry!

austin@austin2:~$ echo $?
1

austin@austin2:~$ bashate foo.pl
E010: Do not on same line as while: ' while (<FILE>) {'
 - foo.pl : L10
1 bashate error(s) found

austin@austin2:~$ echo $?
1

Bashate only fails because it thought there was a style issue, but it is not correct for perl ;)

Revision history for this message
mcandre (andrew-pennebaker) wrote :

As a workaround, the "stank" program can quickly identify shell script files, which can be piped to xargs bashate in order to lint just the shell scripts.

https://github.com/mcandre/stank

Revision history for this message
Austin English (austinenglish) wrote :

I don't know why you'd need a separate (non builtin, go) package. `file` does this just fine:

if [ -d .git ] ; then
    files_to_check="$(git ls-files | xargs file | grep -e 'POSIX shell script' | cut -d : -f1)"
else
    files_to_check="$(find . -type f -exec file {} \; | grep -e 'POSIX shell script' | cut -d : -f1)"
fi

(from https://github.com/Winetricks/winetricks/blob/master/tests/shell-checks#L49)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.