Skip to content

Commit

Permalink
dist/tools/buildsystem_sanity_check: make shellcheck happy
Browse files Browse the repository at this point in the history
The build system sanity check test script currently does not pass
shellcheck, preventing PRs improving it from getting merged.

This commit fixes the issues pointed out by shellcheck and should not
have any functional changes.
  • Loading branch information
maribu committed Jun 4, 2024
1 parent 86e0ca3 commit 0b47100
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions dist/tools/buildsystem_sanity_check/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
: "${RIOTBASE:="$(cd "$(dirname "$0")/../../../" || exit; pwd)"}"

: "${RIOTTOOLS:=${RIOTBASE}/dist/tools}"
# shellcheck source=../ci/github_annotate.sh
. "${RIOTTOOLS}"/ci/github_annotate.sh

Check warning on line 20 in dist/tools/buildsystem_sanity_check/check.sh

View workflow job for this annotation

GitHub Actions / static-tests

Not following: ../ci/github_annotate.sh was not specified as input (see shellcheck -x). [SC1091]

SCRIPT_PATH=dist/tools/buildsystem_sanity_check/check.sh


tab_indent() {
# Ident using 'bashism' to to the tab compatible with 'bsd-sed'
sed 's/^/\'$'\t/'
sed 's/^/\t/'
}

prepend() {
Expand All @@ -34,13 +34,13 @@ prepend() {
}

error_with_message() {
while read INPUT; do
while read -r INPUT; do
if github_annotate_is_on; then
MESSAGE="${1}"
FILE=$(echo "${INPUT}" | cut -d: -f1)
LINE=$(echo "${INPUT}" | cut -d: -f2)
MATCH=$(echo "${INPUT}" | cut -d: -f3)
if [[ $var =~ ^[0-9]+$ ]] || [ -z "$MATCH" ]; then
if [[ $LINE =~ ^[0-9]+$ ]] || [ -z "$MATCH" ]; then
# line is not provided in grep pattern
LINE=0
fi
Expand Down Expand Up @@ -172,7 +172,7 @@ check_not_exporting_variables() {
# Only run if there are patterns, otherwise it matches everything
if [ ${#patterns[@]} -ne 0 ]; then
git -C "${RIOTBASE}" grep -n "${patterns[@]}" -- "${pathspec[@]}" \
| error_with_message 'Variables must only be exported in `makefiles/vars.inc.mk`'
| error_with_message "Variables must only be exported in \`makefiles/vars.inc.mk\`"
fi
}

Expand Down Expand Up @@ -287,14 +287,14 @@ check_files_in_boards_not_reference_board_var() {
local patterns=()
local pathspec=()

patterns+=(-e '/$(BOARD)/')
patterns+=(-e "/\$(BOARD)/")

pathspec+=('boards/')
# boards/common/nrf52 uses a hack to resolve dependencies early
pathspec+=(':!boards/common/nrf52/Makefile.include')

git -C "${RIOTBASE}" grep -n "${patterns[@]}" -- "${pathspec[@]}" \
| error_with_message 'Code in boards/ should not use $(BOARDS) to reference files since this breaks external BOARDS changing BOARDSDIR"'
| error_with_message "Code in boards/ should not use \$(BOARDS) to reference files since this breaks external BOARDS changing BOARDSDIR"
}

check_no_pseudomodules_in_makefile_dep() {
Expand Down Expand Up @@ -415,7 +415,7 @@ all_checks() {

main() {
all_checks | prepend 'Invalid build system patterns found by '"${0}:" | error_on_input >&2
exit $?
return $?
}


Expand Down

0 comments on commit 0b47100

Please # to comment.