lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] Check bashisms in makefiles


From: Vadim Zeitlin
Subject: Re: [lmi] Check bashisms in makefiles
Date: Sun, 23 Oct 2016 15:06:48 +0200

On Sun, 23 Oct 2016 11:38:58 +0000 Greg Chicares <address@hidden> wrote:

GC> Vadim, do you know of a better tool to check for bashisms in makefiles
GC> than 'checkbashisms'?

 I've never actually tried it on anything non-trivial but I do keep in mind
to test ShellCheck (https://github.com/koalaman/shellcheck) for the next
shell script I write (which luckily hasn't happened since quite some time)
as it seems to be quite useful from its description. I wasn't sure if it
supported checking for bashisms, but looking at its man page:

https://github.com/koalaman/shellcheck/blob/master/shellcheck.1.md

it seems like it does, with its "--shell=sh" option. And the example even
mentions that it detects the uses of "((...))" as "not POSIX compliant
(similar to checkbashisms)", so this definitely looks promising.

 Unfortunately after testing it (it's in Debian, so this was simple,
although somewhat disappointing as I was almost looking forward to dusting
off my (barely existent) Haskell skills and compiling it myself), I can say
that running it directly on the makefiles results in tons of warnings
because it detects make constructs as bad shell code. So to use it, the
makefiles would need to be preprocessed and shell code extracted from them.
FWIW the project author considered and rejected the idea of doing it (see
https://github.com/koalaman/shellcheck/issues/58), but I believe it could
be done reasonably well (with my more advanced Perl skills...), if not
perfectly, however it would certainly require more time... Should I look
into doing this?


GC> but the list is incomplete--I know that because when I tried
GC>   $make release_candidate
GC> I saw this, where the last quoted line has an unwanted literal "-e":

 FWIW shellcheck does detect this:

        % echo 'echo -e foo'|shellcheck -s sh -

        In - line 1:
        echo -e foo
             ^-- SC2039: In POSIX sh, echo flags are undefined.

 Regards,
VZ


reply via email to

[Prev in Thread] Current Thread [Next in Thread]