[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <52e64bd1-dd5a-48b4-8acc-c7af5b811d30@linaro.org>
Date: Mon, 23 Jun 2025 09:08:55 +0100
From: James Clark <james.clark@...aro.org>
To: Namhyung Kim <namhyung@...nel.org>
Cc: Collin Funk <collin.funk1@...il.com>, linux-perf-users@...r.kernel.org,
linux-kernel@...r.kernel.org, Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>, Arnaldo Carvalho de Melo <acme@...nel.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>, Ian Rogers <irogers@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>,
"Liang, Kan" <kan.liang@...ux.intel.com>
Subject: Re: [PATCH] perf build: Specify that spellcheck should use the bash
dialect.
On 20/06/2025 8:49 pm, Namhyung Kim wrote:
> Hello,
>
> On Thu, Jun 19, 2025 at 11:28:46AM +0100, James Clark wrote:
>>
>>
>> On 13/06/2025 4:36 am, Collin Funk wrote:
>>> 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.
>>>
>>> Signed-off-by: Collin Funk <collin.funk1@...il.com>
>>> ---
>>> tools/perf/tests/Build | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build
>>> index 2181f5a92148..26efc5d20f6c 100644
>>> --- a/tools/perf/tests/Build
>>> +++ b/tools/perf/tests/Build
>>> @@ -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 -s bash -a -S warning "$<" > $@ || (cat $@ && rm $@ && false)
>>> perf-test-y += $(SHELL_TEST_LOGS)
>>
>> If we're enforcing bash style with static analysis shouldn't we also change
>> all the hashbangs to bash? Recently there have been changes to change sh to
>> bash in some of the tests so presumably the hard rule for sh is no more?
>>
>> In the past I've had to replace bashisms that didn't work in sh but it would
>> be nice to have only one language to write tests in. I doubt anyone running
>> the tests today is running somewhere without bash, or that changing it will
>> break anything. If anything it will fix more bashisms that have already been
>> written.
>>
>> Just for reference there are 34 #!/bin/bash and 42 #!/bin/sh in
>> tools/perf/tests
>
> Thanks for raising the concern. I agree that having one standard is a
> way to go but I really don't have preference between those shells.
>
> Thanks,
> Namhyung
>
I would vote for bash then, just because it has a few extra builtins
that are sometimes useful. I can send a patch that does the change to
see if anyone objects.
Thanks
James
Powered by blists - more mailing lists