perf build: Specify shellcheck should use bash
authorCollin Funk <collin.funk1@gmail.com>
Sat, 28 Jun 2025 03:41:25 +0000 (20:41 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Mon, 30 Jun 2025 16:43:06 +0000 (09:43 -0700)
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: Collin Funk <collin.funk1@gmail.com>
Link: https://lore.kernel.org/r/63491dbc8439edf2e949d80e264b9d22332fea61.1751082075.git.collin.funk1@gmail.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/Build
tools/perf/Makefile.perf
tools/perf/arch/x86/Build
tools/perf/arch/x86/tests/Build
tools/perf/tests/Build
tools/perf/trace/beauty/Build
tools/perf/util/Build

index 06107f1e1d4201e5670ad37f42dda0bc85198b4e..b03cc59dabf81d1132ac16d8a2fe653d4b361f59 100644 (file)
@@ -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)
 
index 62697d62f706081659b27821f3093a417149623f..9b51593628c175182987291cbafdf69dfea310bc 100644 (file)
@@ -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
 
index afae7b8f6bd61c637d0839c2ef24144787f360ce..d31a1168757cb3c240997b9ff3c1fb1db5fab600 100644 (file)
@@ -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)
index 5e00cbfd2d569bb9ea255d733d350efbac1d858a..01d5527f38c788c689974a2dc5497d1057f1e690 100644 (file)
@@ -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)
index 2181f5a92148b0b90a430d6d9b38919dea105850..d6c35dd0de3bd6cea6f0a23cd92a515788fcb913 100644 (file)
@@ -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)
 
index f50ebdc445b817cf1f637f7831a2fece591a0877..561590ee8cda6fed52433c5334bf59a65c8886b2 100644 (file)
@@ -31,6 +31,6 @@ 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)
index 45515b8f615ab8c807454981a038780eda219333..12bc01c843b2c57d328ff5e11ccd654ff3e1cd4b 100644 (file)
@@ -424,7 +424,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-util-y += $(SHELL_TEST_LOGS)