Skip to content

treewide: fix shellcheck errors to pass static-tests again - #22654

Open
crasbe wants to merge 3 commits into
RIOT-OS:masterfrom
crasbe:pr/shellcheck_errors
Open

treewide: fix shellcheck errors to pass static-tests again#22654
crasbe wants to merge 3 commits into
RIOT-OS:masterfrom
crasbe:pr/shellcheck_errors

Conversation

@crasbe

@crasbe crasbe commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Contribution description

This PR fixes the errors detected by shellcheck. This does not cover warnings, which remain plenty.
The reason is that fixing warnings can cause a lot of breakage and I'd instead like to get our static tests to pass again.

Testing procedure

I'll provide explicit test traces where possible in review comments later on.

The following errors were present before:

buechse@skyleaf:~/RIOTstuff/riot-vanillaschote/RIOT$ docker run --rm --tty --user $(id -u):$(id -g) --platform linux/amd64 -v '/home/buechse/RIOTstuff/riot-fresh/RIOT:/data/riotbuild/riotbase:delegated' -v '/home/buechse/.cargo/registry:/data/riotbuild/.cargo/registry:delegated' -v '/home/buechse/.cargo/git:/data/riotbuild/.cargo/git:delegated' -e 'TZ=Europe/Berlin' -e 'RIOTBASE=/data/riotbuild/riotbase' -e 'CCACHE_BASEDIR=/data/riotbuild/riotbase' -e 'BUILD_DIR=/data/riotbuild/riotbase/build' -e 'BUILD_IN_DOCKER=0' -w '/data/riotbuild/riotbase' -e CI_BASE_BRANCH -e GITHUB_RUN_ID=5 '5ebf563ef282' make static-test

...

::error file=dist/tools/cppcheck/check.sh,line=62::Double quote array expansions to avoid re-splitting elements. [SC2068]
::error file=dist/tools/genconfigheader/genconfigheader.sh,line=19::Argument mixes string and array. Use * or separate argument. [SC2145]
::error file=dist/tools/lpc2k_pgm/flashutil.sh,line=106::Since you double quoted this, it will not word split, and the loop will only run once. [SC2066]
::error file=dist/tools/lpc2k_pgm/flashutil.sh,line=1::Use #!, not just #, for the shebang. [SC1113]
::error file=dist/tools/mspdebug/debug.sh,line=12::Braces are required for positionals over 9, e.g. ${10}. [SC1037]
::error file=pkg/relic/os_util.sh,line=1::Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive. [SC2148]
::warning file=boards/f4vi1/dist/debug.sh,line=4::Double quote to prevent globbing and word splitting. [SC2086]
::warning file=boards/hifive1/dist/flasher.sh,line=39::This default assignment may cause DoS due to globbing. Quote it. [SC2223]
::warning file=boards/hifive1/dist/flasher.sh,line=45::This default assignment may cause DoS due to globbing. Quote it. [SC2223]
::warning file=boards/hifive1/dist/flasher.sh,line=49::This default assignment may cause DoS due to globbing. Quote it. [SC2223]
::warning file=boards/mbed_lpc1768/dist/flash.sh,line=21::Use $(...) notation instead of legacy backticks `...`. [SC2006]
...

Now no errors remain, just warnings (and plenty thereof...):

buechse@skyleaf:~/RIOTstuff/riot-vanillaschote/RIOT$ docker run --rm --tty --user $(id -u):$(id -g) --platform linux/amd64 -v '/home/buechse/RIOTstuff/riot-vanillaschote/RIOT:/data/riotbuild/riotbase:delegated' -v '/home/buechse/.cargo/registry:/data/riotbuild/.cargo/registry:delegated' -v '/home/buechse/.cargo/git:/data/riotbuild/.cargo/git:delegated' -e 'TZ=Europe/Berlin' -e 'RIOTBASE=/data/riotbuild/riotbase' -e 'CCACHE_BASEDIR=/data/riotbuild/riotbase' -e 'BUILD_DIR=/data/riotbuild/riotbase/build' -e 'BUILD_IN_DOCKER=0' -w '/data/riotbuild/riotbase' -e CI_BASE_BRANCH -e GITHUB_RUN_ID=5 '5ebf563ef282' make static-test

...

::warning file=boards/f4vi1/dist/debug.sh,line=4::Double quote to prevent globbing and word splitting. [SC2086]
::warning file=boards/hifive1/dist/flasher.sh,line=39::This default assignment may cause DoS due to globbing. Quote it. [SC2223]
::warning file=boards/hifive1/dist/flasher.sh,line=45::This default assignment may cause DoS due to globbing. Quote it. [SC2223]
::warning file=boards/hifive1/dist/flasher.sh,line=49::This default assignment may cause DoS due to globbing. Quote it. [SC2223]
::warning file=boards/mbed_lpc1768/dist/flash.sh,line=21::Use $(...) notation instead of legacy backticks `...`. [SC2006]
::warning file=boards/mbed_lpc1768/dist/flash.sh,line=27::Double quote to prevent globbing and word splitting. [SC2086]
::warning file=boards/mbed_lpc1768/dist/flash.sh,line=30::Double quote to prevent globbing and word splitting. [SC2086]
::warning file=boards/mbed_lpc1768/dist/flash.sh,line=42::Double quote to prevent globbing and word splitting. [SC2086]

Issues/PRs references

Progress for tracking issue #22216

Declaration of AI-Tools / LLMs usage:

AI-Tools / LLMs that were used are:

  • asked Claude to review the changes and determine whether or not something might break

@crasbe
crasbe requested a review from kfessel September 3, 2026 12:34
@crasbe crasbe added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR AI: Ducky PR/Issue uses AI for asking questions, AI was not involved in final product. labels Sep 3, 2026
@github-actions github-actions Bot added Area: pkg Area: External package ports Area: tools Area: Supplementary tools labels Sep 3, 2026
Comment thread pkg/relic/os_util.sh
@@ -1,3 +1,5 @@
# shellcheck shell=bash

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uncritical change.

ELFFILE="$8"
PREFIX="$9"
RIOTBASE="$10"
RIOTBASE="${10}"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For numbers >=10, the brackets have to be used, I don't expect any breakage here.

@@ -1,4 +1,4 @@
#/usr/bin/env bash
#!/usr/bin/env bash

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uncritical change, just fixed the shebang, no testing required.

Comment thread dist/tools/cppcheck/check.sh Outdated
cppcheck --std=c99 --enable=style --force --error-exitcode=2 --quiet -j 1 \
--template "{file}:{line}: {severity} ({id}): {message}" \
--inline-suppr ${DEFAULT_SUPPRESSIONS} ${CPPCHECK_OPTIONS} ${@} \
--inline-suppr ${DEFAULT_SUPPRESSIONS} ${CPPCHECK_OPTIONS} "${@}" \

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before the change:

buechse@skyleaf:~/RIOTstuff/riot-vanillaschote/RIOT$ docker run --rm --tty --user $(id -u):$(id -g) --platform linux/amd64 -v '/home/buechse/RIOTstuff/riot-vanillaschote/RIOT:/data/riotbuild/riotbase:delegated' -v '/home/buechse/.cargo/registry:/data/riotbuild/.cargo/registry:delegated' -v '/home/buechse/.cargo/git:/data/riotbuild/.cargo/git:delegated' -e 'TZ=Europe/Berlin' -e 'RIOTBASE=/data/riotbuild/riotbase' -e 'CCACHE_BASEDIR=/data/riotbuild/riotbase' -e 'BUILD_DIR=/data/riotbuild/riotbase/build' -e 'BUILD_IN_DOCKER=0' -w '/data/riotbuild/riotbase' -e CI_BASE_BRANCH -e GITHUB_RUN_ID=5 '5ebf563ef282' ./dist/tools/cppcheck/check.sh
boards/adafruit-pybadge/board.c:25: error (syntaxError): failed to evaluate #if condition, undefined function-like macro invocation: IS_USED( ... )
boards/common/esp32x/board_common.c:42: error (syntaxError): failed to evaluate #if condition, undefined function-like macro invocation: IS_USED( ... )
boards/common/esp32x/include/periph_conf_common.h:342: error (syntaxError): failed to evaluate #if condition, undefined function-like macro invocation: IS_USED( ... )
boards/common/esp32x/include/periph_conf_common.h:36: error (preprocessorErrorDirective): #error "ESP32x SoC family not supported"
boards/common/kw41z/include/periph_conf_common.h:49: style (badBitmaskCheck): Operator '|' with one operand equal to zero is redundant.
boards/common/native/board_init.c:86: error (unknownMacro): There is an unknown macro here somewhere. Configuration is required. If RIOT_BOARD is a macro then please configure it.
boards/common/native/include/gpio_params.h:25: error (syntaxError): failed to evaluate #if condition, undefined function-like macro invocation: IS_USED( ... )
boards/common/particle-mesh/bootloader.c:43: error (unknownMacro): There is an unknown macro here somewhere. Configuration is required. If ISR_VECTOR is a macro then please configure it.
boards/common/particle-mesh/include/board.h:104: error (syntaxError): failed to evaluate #if condition, undefined function-like macro invocation: IS_USED( ... )
boards/common/silabs/drivers/bc/bc.c:35: error (syntaxError): failed to evaluate #if condition, undefined function-like macro invocation: UART_DEV( ... )
boards/common/slwstk6000b/include/board.h:38: error (syntaxError): failed to evaluate #if condition, undefined function-like macro invocation: IS_ACTIVE( ... )
boards/common/stm32/include/stm32_leds.h:39: error (syntaxError): failed to evaluate #if condition, undefined function-like macro invocation: IS_ACTIVE( ... )
boards/common/stm32/include/stm32_leds.h:52: error (syntaxError): failed to evaluate #if condition, undefined function-like macro invocation: IS_ACTIVE( ... )

After the change:

buechse@skyleaf:~/RIOTstuff/riot-vanillaschote/RIOT$ docker run --rm --tty --user $(id -u):$(id -g) --platform linux/amd64 -v '/home/buechse/RIOTstuff/riot-vanillaschote/RIOT:/data/riotbuild/riotbase:delegated' -v '/home/buechse/.cargo/registry:/data/riotbuild/.cargo/registry:delegated' -v '/home/buechse/.cargo/git:/data/riotbuild/.cargo/git:delegated' -e 'TZ=Europe/Berlin' -e 'RIOTBASE=/data/riotbuild/riotbase' -e 'CCACHE_BASEDIR=/data/riotbuild/riotbase' -e 'BUILD_DIR=/data/riotbuild/riotbase/build' -e 'BUILD_IN_DOCKER=0' -w '/data/riotbuild/riotbase' -e CI_BASE_BRANCH -e GITHUB_RUN_ID=5 '5ebf563ef282' ./dist/tools/cppcheck/check.sh
boards/adafruit-pybadge/board.c:25: error (syntaxError): failed to evaluate #if condition, undefined function-like macro invocation: IS_USED( ... )
boards/common/esp32x/board_common.c:42: error (syntaxError): failed to evaluate #if condition, undefined function-like macro invocation: IS_USED( ... )
boards/common/esp32x/include/periph_conf_common.h:342: error (syntaxError): failed to evaluate #if condition, undefined function-like macro invocation: IS_USED( ... )
boards/common/esp32x/include/periph_conf_common.h:36: error (preprocessorErrorDirective): #error "ESP32x SoC family not supported"
boards/common/kw41z/include/periph_conf_common.h:49: style (badBitmaskCheck): Operator '|' with one operand equal to zero is redundant.
boards/common/native/board_init.c:86: error (unknownMacro): There is an unknown macro here somewhere. Configuration is required. If RIOT_BOARD is a macro then please configure it.
boards/common/native/include/gpio_params.h:25: error (syntaxError): failed to evaluate #if condition, undefined function-like macro invocation: IS_USED( ... )
boards/common/particle-mesh/bootloader.c:43: error (unknownMacro): There is an unknown macro here somewhere. Configuration is required. If ISR_VECTOR is a macro then please configure it.
boards/common/particle-mesh/include/board.h:104: error (syntaxError): failed to evaluate #if condition, undefined function-like macro invocation: IS_USED( ... )
boards/common/silabs/drivers/bc/bc.c:35: error (syntaxError): failed to evaluate #if condition, undefined function-like macro invocation: UART_DEV( ... )
boards/common/slwstk6000b/include/board.h:38: error (syntaxError): failed to evaluate #if condition, undefined function-like macro invocation: IS_ACTIVE( ... )
boards/common/stm32/include/stm32_leds.h:39: error (syntaxError): failed to evaluate #if condition, undefined function-like macro invocation: IS_ACTIVE( ... )
boards/common/stm32/include/stm32_leds.h:52: error (syntaxError): failed to evaluate #if condition, undefined function-like macro invocation: IS_ACTIVE( ... )

--template "{file}:{line}: {severity} ({id}): {message}" \
--inline-suppr ${DEFAULT_SUPPRESSIONS} ${CPPCHECK_OPTIONS} ${@} \
cppcheck --std=c99 --enable=style --force --error-exitcode=2 --quiet -j 1 \
--template="{file}:{line}: {severity} ({id}): {message}" \

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The static test didn't even work before adding the =:

buechse@skyleaf:~/RIOTstuff/riot-vanillaschote/RIOT$ docker run --rm --tty --user $(id -u):$(id -g) --platform linux/amd64 -v '/home/buechse/RIOTstuff/riot-vanillaschote/RIOT:/data/riotbuild/riotbase:delegated' -v '/home/buechse/.cargo/registry:/data/riotbuild/.cargo/registry:delegated' -v '/home/buechse/.cargo/git:/data/riotbuild/.cargo/git:delegated' -e 'TZ=Europe/Berlin' -e 'RIOTBASE=/data/riotbuild/riotbase' -e 'CCACHE_BASEDIR=/data/riotbuild/riotbase' -e 'BUILD_DIR=/data/riotbuild/riotbase/build' -e 'BUILD_IN_DOCKER=0' -w '/data/riotbuild/riotbase' -e CI_BASE_BRANCH -e GITHUB_RUN_ID=5 '5ebf563ef282' ./dist/tools/cppcheck/check.sh
cppcheck: error: unrecognized command line option: "--template".


echo "/* DO NOT edit this file, your changes will be overwritten and won't take any effect! */"
echo "/* Generated from CFLAGS: $@ */"
echo "/* Generated from CFLAGS: $* */"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still works as before:

buechse@skyleaf:~/RIOTstuff/riot-vanillaschote/RIOT$ git checkout pr/shellcheck_errors
Switched to branch 'pr/shellcheck_errors'

buechse@skyleaf:~/RIOTstuff/riot-vanillaschote/RIOT$ ./dist/tools/genconfigheader/genconfigheader.sh > pr.txt

buechse@skyleaf:~/RIOTstuff/riot-vanillaschote/RIOT$ git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.

buechse@skyleaf:~/RIOTstuff/riot-vanillaschote/RIOT$ ./dist/tools/genconfigheader/genconfigheader.sh > master.txt

buechse@skyleaf:~/RIOTstuff/riot-vanillaschote/RIOT$ diff master.txt pr.txt

### wait for all flasher processes to finish
echo Waiting until all devices have been programmed...
for pid in "${pids}"; do
for pid in ${pids}; do

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't test this, but previously only one element would've been iterated as in this case, the word splitting would be intended.

@riot-ci

riot-ci commented Sep 3, 2026

Copy link
Copy Markdown

Murdock results

✔️ PASSED

7f559ea fixup! dist/tools: fix shellcheck errors

Success Failures Total Runtime
11284 0 11285 15m:47s

Artifacts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI: Ducky PR/Issue uses AI for asking questions, AI was not involved in final product. Area: pkg Area: External package ports Area: tools Area: Supplementary tools CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants