shellcheck icon indicating copy to clipboard operation
shellcheck copied to clipboard

SC3045 with busybox shell: "In dash, export -n is not supported."

Open airtower-luna opened this issue 4 months ago • 1 comments

For bugs with existing features

  • Rule Id: SC3045
  • My shellcheck version: 0.11.0 (Debian Sid package 0.11.0-1)
  • [x] The rule's wiki page does not already cover this (e.g. https://shellcheck.net/wiki/SC2086)
  • [x] I tried on https://www.shellcheck.net/ and verified that this is still a problem on the latest commit

Here's a snippet or screenshot that shows the problem:

# shellcheck shell=busybox
test="1234"
export test
jq -n '{test: env.test}'
export -n test
jq -n '{test: env.test}'

Here's what shellcheck currently says:

Line 5:
export -n test
       ^-- SC3045 (error): In dash, export -n is not supported.

Here's what I wanted or expected to see:

No error. Busybox supports export -n (tested with v1.37.0), as running the example commands shows:

# export test=1234
# jq -n '{test: env.test}'
{
  "test": "1234"
}
# export -n test
# jq -n '{test: env.test}'
{
  "test": null
}

Also if there was an issue, I'd expect the selected busybox shell to be mentioned, not dash.

airtower-luna avatar Aug 19 '25 11:08 airtower-luna

Indeed. Probably some kind of aliasing going on for the rule indeed. busybox ash support stuff that the debian ash doesn't.

brother avatar Aug 19 '25 12:08 brother