Thread View: linux.debian.bugs.dist
3 messages
3 total messages
Started by Benjamin Drung
Mon, 23 Nov 2026 13:40
Bug#1155004: lintian: Please use shellcheck to check for bashisms
Author: Benjamin Drung
Date: Mon, 23 Nov 2026 13:40
Date: Mon, 23 Nov 2026 13:40
25 lines
2352 bytes
2352 bytes
Package: lintian Version: 2.144.0 Severity: wishlist X-Debbugs-Cc: bdrung@debian.org Dear Maintainer, I have seen several false positives for the bashisms checks, for example: * bash-term-in-posix-shell false positive, triggers on "function" in an embedded awk script (bug #1029223) * bash-term-in-posix-shell false positives for dracut (#1155003) There is a tool that parses shell scripts and is good at detecting script problems including bashisms: shellcheck Please use shellcheck for bash-term-in-posix-shell and chown-with-dot. It can produce a JSON output that lintian can use. shellcheck can take --rcfile to specify a config. In this config, lintian could turn on the shellcheck checks about bashisms. -- Benjamin Drung Debian & Ubuntu Developer
Bug#1155004: lintian: Please use shellcheck to check for bashisms
Author: Nilesh Patra
Date: Mon, 30 Nov 2026 15:50
Date: Mon, 30 Nov 2026 15:50
38 lines
3739 bytes
3739 bytes
On 23/11/26 7:00 pm, Benjamin Drung wrote: > Package: lintian > Version: 2.144.0 > Severity: wishlist > X-Debbugs-Cc: bdrung@debian.org > > Dear Maintainer, > > I have seen several false positives for the bashisms checks, for > example: > > * bash-term-in-posix-shell false positive, triggers on "function" in an > embedded awk script (bug #1029223) > * bash-term-in-posix-shell false positives for dracut (#1155003) > > There is a tool that parses shell scripts and is good at detecting > script problems including bashisms: shellcheck > > Please use shellcheck for bash-term-in-posix-shell and chown-with-dot. > It can produce a JSON output that lintian can use. shellcheck can take > --rcfile to specify a config. In this config, lintian could turn on the > shellcheck checks about bashisms. I initially thought if it is possible to directly use `checkbashism` from `devscripts` but it seems like even that has false positives (the code in lintian seems to have been inspired from there). shellcheck can make sense indeed, but it does not cover all heuristics that we currently have. For example, checks for `shopt`, `unalias -a`, `SHLVL` etc are missing. OTOH, parsing shellcheck output and making it exactly similar to current lintian output ensuring no regression is a bit tricky. Maybe the output format in lintian will need to change. Do you have thoughts/advice? Thanks, Nilesh
Bug#1155004: lintian: Please use shellcheck to check for bashisms
Author: Benjamin Drung
Date: Tue, 01 Dec 2026 11:40
Date: Tue, 01 Dec 2026 11:40
85 lines
4478 bytes
4478 bytes
On Mon, 2026-11-30 at 21:11 +0530, Nilesh Patra wrote:
>
> On 23/11/26 7:00 pm, Benjamin Drung wrote:
> > Package: lintian
> > Version: 2.144.0
> > Severity: wishlist
> > X-Debbugs-Cc: bdrung@debian.org
> >
> > Dear Maintainer,
> >
> > I have seen several false positives for the bashisms checks, for
> > example:
> >
> > * bash-term-in-posix-shell false positive, triggers on "function" in an
> > embedded awk script (bug #1029223)
> > * bash-term-in-posix-shell false positives for dracut (#1155003)
> >
> > There is a tool that parses shell scripts and is good at detecting
> > script problems including bashisms: shellcheck
> >
> > Please use shellcheck for bash-term-in-posix-shell and chown-with-dot.
> > It can produce a JSON output that lintian can use. shellcheck can take
> > --rcfile to specify a config. In this config, lintian could turn on the
> > shellcheck checks about bashisms.
>
> I initially thought if it is possible to directly use `checkbashism` from `devscripts`
> but it seems like even that has false positives (the code in lintian seems to have been
> inspired from there).
We should probably ditch checkbashism in favor of shellcheck (after
checking that shellcheck have all the same checks).
> shellcheck can make sense indeed, but it does not cover all heuristics that we currently
> have. For example, checks for `shopt`, `unalias -a`, `SHLVL` etc are missing.
For the checks that are missing: Report that to shellcheck to add those.
> OTOH, parsing
> shellcheck output and making it exactly similar to current lintian output ensuring no
> regression is a bit tricky. Maybe the output format in lintian will need to change.
How much backward compatibility is needed? I have no strong opinion
about this one.
Out of curiosity, I just tested one case:
bash-term-in-posix-shell 'echo -e' [usr/bin/two:93]
example script:
```
#!/bin/sh
echo -e foo
```
shellcheck complains:
```
$ shellcheck ./foo
In ./foo line 2:
echo -e foo
^-- SC3037 (warning): In POSIX sh, echo flags are undefined.
```
or in JSON:
```
$ shellcheck --format=json1 ./foo
{"comments":[{"file":"./foo","line":2,"endLine":2,"column":6,"endColumn":8,"level":"warning","code":3037,"message":"In POSIX sh, echo flags are undefined.","fix":null}]}
```
So we have "file", "line", "code" in the output that can be used.
Code 3037 would map to bash-term-in-posix-shell
--
Benjamin Drung
Debian & Ubuntu Developer
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads