Skip to content

Commit

Permalink
scripts: checkpatch: fix word splitting in the command
Browse files Browse the repository at this point in the history
The following would fail with Zsh instead of Bash :
$ source ./scripts/checkpatch_inc.sh
$ checkpatch HEAD
Unknown option: typedefsfile typedefs.checkpatch
Usage: .../scripts/checkpatch.pl [OPTION]... [FILE]

By setting xtrace in the _checkpatch() function, we can see the built
command is interpreted differently depending on the shell:
	$CHECKPATCH $CHECKPATCH_OPT $typedefs_opt -
In Zsh:
	/scripts/checkpatch.pl '--typedefsfile typedefs.checkpatch' -
In Bash:
	/scripts/checkpatch.pl --typedefsfile typedefs.checkpatch -

Bash differs from Zsh when it comes to word splitting for unquoted
parameters expansions.
One solution is to use `eval` to execute the built command.

Signed-off-by: Clement Faure <clement.faure@nxp.com>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
  • Loading branch information
clementfaure authored and jforissier committed Dec 11, 2023
1 parent e1bfa2f commit 79f8990
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/checkpatch_inc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function _checkpatch() {
typedefs_opt="";
# Ignore NOT_UNIFIED_DIFF in case patch has no diff
# (e.g., all paths filtered out)
$CHECKPATCH $CHECKPATCH_OPT $typedefs_opt -
eval "$CHECKPATCH $CHECKPATCH_OPT $typedefs_opt -"
}

function checkpatch() {
Expand Down

0 comments on commit 79f8990

Please sign in to comment.