You are not logged in.

#1 2025-11-24 23:51:49

Gregory_M
Member
Registered: 2024-11-30
Posts: 35

"checkbashisms" Results Require Confirmation?

Is checkbashisms expected to flag potential syntax that may not actually be bashisms, with the idea being that if one can rule out that all items flagged are actually OK, then dash can be used as /bin/sh?

For example checkbashisms is reporting:

possible bashism in /usr/bin/xdg-desktop-icon line 276 (alternative test command (

[[ foo ]]

should be

[ foo ]

And  it shows the code in question  as:

command="$(grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | first_word)"

So it appears to be flagging

[[

which in its context:

Exec(...)

does not appear to be a test (conditional) command.

Last edited by Gregory_M (2025-11-24 23:52:42)

Offline

#2 2025-11-24 23:59:23

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,619
Website

Re: "checkbashisms" Results Require Confirmation?

Gregory_M wrote:

Is checkbashisms expected to flag potential syntax that may not actually be bashisms, with the idea being that if one can rule out that all items flagged are actually OK, then dash can be used as /bin/sh?

Excluding false positives does mean they are not issues.  It is more difficult to exclude false negatives.

Offline

#3 2025-11-25 00:07:05

Gregory_M
Member
Registered: 2024-11-30
Posts: 35

Re: "checkbashisms" Results Require Confirmation?

Allan wrote:

Excluding false positives does mean they are not issues.  It is more difficult to exclude false negatives.

Thank you for response.

I will clarify my question. Does checkbashisms sometimes report findings that are not necessarily bashisms, such that the checkbashisms output results should be reviewed to determine whether reported item(s) are indeed bashisms?

Last edited by Gregory_M (2025-11-25 00:12:40)

Offline

#4 2025-11-25 01:32:57

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,619
Website

Re: "checkbashisms" Results Require Confirmation?

You provided an example where checkbashisms reported something that was not a bashism.   So, yes...

Offline

#5 2025-11-25 02:12:15

Gregory_M
Member
Registered: 2024-11-30
Posts: 35

Re: "checkbashisms" Results Require Confirmation?

Allan wrote:

You provided an example where checkbashisms reported something that was not a bashism...

Thank you kindly for confirming my example.

Last edited by Gregory_M (2025-11-25 22:44:24)

Offline

#6 2025-11-25 06:29:08

system72
Member
Registered: 2025-11-22
Posts: 349
Website

Re: "checkbashisms" Results Require Confirmation?

have you tried shellcheck instead?

Offline

#7 2025-11-25 09:50:18

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 71,549

Re: "checkbashisms" Results Require Confirmation?

the idea being that if one can rule out that all items flagged are actually OK, then dash can be used as /bin/sh?

False positives are way less critical and easier to deal with, so a smart tool will bias there but, there's no guarantee and you need expect them all to miss some false-negatives.
As you figured from your false-positive, they're more or less running basic greps.

The purpose is to assist you w/ automated checks, not to verify and validate code.

Offline

#8 2025-11-25 22:51:59

Gregory_M
Member
Registered: 2024-11-30
Posts: 35

Re: "checkbashisms" Results Require Confirmation?

seth wrote:

False positives are way less critical and easier to deal with, so a smart tool will bias there but, there's no guarantee and you need expect them all to miss some false-negatives.
The purpose is to assist you w/ automated checks, not to verify and validate code.

OK. Thank You.

@Allan also spoke of false negatives.

Does "false negative" refer to an actual bashism that is only used if a check in the containing script determines that the shell supports it?

Last edited by Gregory_M (2025-11-25 22:59:21)

Offline

#9 2025-11-25 22:56:05

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 71,549

Re: "checkbashisms" Results Require Confirmation?

https://en.wikipedia.org/wiki/False_pos … tive_error just means that the check misses actual bashisms in the script (because of quoting, line breaks, evaluation, variable expansion, …)

Offline

#10 2025-11-25 22:58:18

Gregory_M
Member
Registered: 2024-11-30
Posts: 35

Re: "checkbashisms" Results Require Confirmation?

system72 wrote:

have you tried shellcheck instead?

I wasn't aware of it. Thank you for making me aware of it.

Offline

#11 2025-11-25 23:06:26

Gregory_M
Member
Registered: 2024-11-30
Posts: 35

Re: "checkbashisms" Results Require Confirmation?

seth wrote:

https://en.wikipedia.org/wiki/False_pos … tive_error just means that the check misses actual bashisms in the script (because of quoting, line breaks, evaluation, variable expansion, …)

Thanks much.

Offline

Board footer

Powered by FluxBB