Article View: linux.debian.bugs.dist
Article #6990Bug#1155004: lintian: Please use shellcheck to check for bashisms
From: 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
Technical Details
Message-ID:
<O5unf-fk0h-9@gated-at.bofh.it>Path:
mbox-mo1.pugleaf.net!news-ams.pugleaf.net!news.tcpreset.net!newsfeed.bofh.team!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!bofh.it!news.nic.it!robomodReferences:
<O2CqZ-dG1h-7@gated-at.bofh.it> <O5bND-f8Yc-5@gated-at.bofh.it> <O2CqZ-dG1h-7@gated-at.bofh.it> <O5bND-f8Yc-5@gated-at.bofh.it>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-ams.pugleaf.net!news.tcpreset.net!newsfeed.bofh.team!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!bofh.it!news.nic.it!robomod From: Benjamin Drung <bdrung@debian.org> Newsgroups: linux.debian.bugs.dist Subject: Bug#1155004: lintian: Please use shellcheck to check for bashisms Date: Tue, 01 Dec 2026 12:40:01 +0100 Message-ID: <O5unf-fk0h-9@gated-at.bofh.it> References: <O2CqZ-dG1h-7@gated-at.bofh.it> <O5bND-f8Yc-5@gated-at.bofh.it> <O2CqZ-dG1h-7@gated-at.bofh.it> <O5bND-f8Yc-5@gated-at.bofh.it> X-Mailbox-Line: From debian-bugs-dist-request@lists.debian.org Tue Dec 1 11:37:07 2026 Old-Return-Path: <debbugs@buxtehude.debian.org> X-Spam-Flag: NO X-Spam-Score: -1.7 Reply-To: Benjamin Drung <bdrung@debian.org>, 1155004@bugs.debian.org Resent-To: debian-bugs-dist@lists.debian.org Resent-Cc: lintian-maint@debian.org X-Debian-Pr-Message: followup 1155004 X-Debian-Pr-Package: lintian X-Debian-Pr-Source: lintian Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2-9 MIME-Version: 1.0 X-Debian-User: bdrung X-Debian-Message: from BTS X-Mailing-List: <debian-bugs-dist@lists.debian.org> archive/latest/2006269 List-ID: <debian-bugs-dist.lists.debian.org> List-URL: <https://lists.debian.org/debian-bugs-dist/> Approved: robomod@news.nic.it Lines: 85 Organization: linux.* mail to news gateway Sender: robomod@news.nic.it X-Original-Date: Tue, 01 Dec 2026 12:35:14 +0100 X-Original-Message-ID: <ffa08d39ba04b10d7918dcd7ee9b342f74827e98.camel@debian.org> X-Original-References: <179544064001.1956470.10220455099642143787.reportbug@deep-thought> <02060be4-040d-4a0f-bd24-5920a1aaabb2@debian.org> <179544064001.1956470.10220455099642143787.reportbug@deep-thought> <02060be4-040d-4a0f-bd24-5920a1aaabb2@debian.org>