From 79f8990d9d28539864d8f97f9f1cb32e289e595f Mon Sep 17 00:00:00 2001 From: Clement Faure Date: Mon, 4 Dec 2023 17:23:34 +0100 Subject: [PATCH] scripts: checkpatch: fix word splitting in the command 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 Acked-by: Jerome Forissier --- scripts/checkpatch_inc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/checkpatch_inc.sh b/scripts/checkpatch_inc.sh index fb77d5ca2f9..166774af53a 100644 --- a/scripts/checkpatch_inc.sh +++ b/scripts/checkpatch_inc.sh @@ -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() {