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: [email protected]
> >
> > 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