Commit 114339ee authored by Collin Funk's avatar Collin Funk Committed by Namhyung Kim
Browse files

perf build: Specify shellcheck should use bash

When someone has a global shellcheckrc file, for example at
~/.config/shellcheckrc, with the directive 'shell=sh', building perf
will fail with many shellcheck errors like:

    In tests/shell/base_probe/test_adding_kernel.sh line 294:
    (( TEST_RESULT += $? ))
    ^---------------------^ SC3006 (warning): In POSIX sh, standalone ((..)) is undefined.

    For more information:
      https://www.shellcheck.net/wiki/SC3006

 -- In POSIX sh, standalone ((..)) is...
    make[5]: *** [tests/Build:91: tests/shell/base_probe/test_adding_kernel.sh.shellcheck_log] Error 1

Passing the '-s bash' option ensures that it runs correctly regardless
of a developers global configuration.

This patch adds '-s bash' and other options to the SHELLCHECK variable
in Makefile.perf and makes use of the variable consistently.

Signed-off-by: default avatarCollin Funk <collin.funk1@gmail.com>
Link: https://lore.kernel.org/r/63491dbc8439edf2e949d80e264b9d22332fea61.1751082075.git.collin.funk1@gmail.com


Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
parent 14684793
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ endif

$(OUTPUT)%.shellcheck_log: %
	$(call rule_mkdir)
	$(Q)$(call echo-cmd,test)shellcheck -s bash -a -S warning "$<" > $@ || (cat $@ && rm $@ && false)
	$(Q)$(call echo-cmd,test)$(SHELLCHECK) "$<" > $@ || (cat $@ && rm $@ && false)

perf-y += $(SHELL_TEST_LOGS)

+2 −0
Original line number Diff line number Diff line
@@ -259,6 +259,8 @@ ifneq ($(SHELLCHECK),)
  ifeq ($(shell expr $(shell $(SHELLCHECK) --version | grep version: | \
        sed -e 's/.\+ \([0-9]\+\).\([0-9]\+\).\([0-9]\+\)/\1\2\3/g') \< 060), 1)
    SHELLCHECK :=
  else
    SHELLCHECK := $(SHELLCHECK) -s bash -a -S warning
  endif
endif

+1 −1
Original line number Diff line number Diff line
@@ -10,6 +10,6 @@ endif

$(OUTPUT)%.shellcheck_log: %
	$(call rule_mkdir)
	$(Q)$(call echo-cmd,test)shellcheck -a -S warning "$<" > $@ || (cat $@ && rm $@ && false)
	$(Q)$(call echo-cmd,test)$(SHELLCHECK) "$<" > $@ || (cat $@ && rm $@ && false)

perf-test-y += $(SHELL_TEST_LOGS)
+1 −1
Original line number Diff line number Diff line
@@ -22,6 +22,6 @@ endif

$(OUTPUT)%.shellcheck_log: %
	$(call rule_mkdir)
	$(Q)$(call echo-cmd,test)shellcheck -a -S warning "$<" > $@ || (cat $@ && rm $@ && false)
	$(Q)$(call echo-cmd,test)$(SHELLCHECK) "$<" > $@ || (cat $@ && rm $@ && false)

perf-test-y += $(SHELL_TEST_LOGS)
+1 −1
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ endif

$(OUTPUT)%.shellcheck_log: %
	$(call rule_mkdir)
	$(Q)$(call echo-cmd,test)shellcheck -a -S warning "$<" > $@ || (cat $@ && rm $@ && false)
	$(Q)$(call echo-cmd,test)$(SHELLCHECK) "$<" > $@ || (cat $@ && rm $@ && false)

perf-test-y += $(SHELL_TEST_LOGS)

Loading