shellcheck icon indicating copy to clipboard operation
shellcheck copied to clipboard

SC3028 with busybox shell: "In dash, RANDOM is not supported."

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

For bugs with existing features

  • Rule Id (if any, e.g. SC1000): SC3028
  • My shellcheck version (shellcheck --version or "online"): 0.11.0
  • [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
echo "$RANDOM"

Here's what shellcheck currently says:

[Line 2:](javascript:setPosition(2, 7))
echo "$RANDOM"
      ^-- [SC3028](https://www.shellcheck.net/wiki/SC3028) (error): In dash, RANDOM is not supported.

Here's what I wanted or expected to see:

No error. Busybox ash supports RANDOM, example output:

# echo $RANDOM
14948
# echo $RANDOM
11702

The mention of "dash" in the output indicates the shell type isn't handled correctly.

airtower-luna avatar Aug 29 '25 18:08 airtower-luna

In my opinion I also think that shell=busybox doesn't make sense, busybox contains ash and hush (and bash and sh but only as alias of ash); also in the past there were also more shells.

I think it make sens to create a separate entry for ash (that isn't dash although similar), maybe by renaming busybox to ash in the code.

ale5000-git avatar Aug 29 '25 19:08 ale5000-git