Shellcheck warnings SC2327,SC2328 complain that a command substitution will be empty if the output is redirected, which is a valid warning but shellcheck is not smart enough to see when output is redirected into a command that outputs what the command substitution wanted. Add comments and shellcheck directives to these cases. Signed-off-by: Nicholas Piggin --- scripts/arch-run.bash | 9 +++++++++ scripts/runtime.bash | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash index 58e4f93f..9c089f88 100644 --- a/scripts/arch-run.bash +++ b/scripts/arch-run.bash @@ -9,6 +9,11 @@ run_test () # stdout to {stdout}, stderr to $errors and stderr exec {stdout}>&1 + # SC complains that redirection without tee takes output way from + # command substitution, but that is what we want here (stderr output + # does go to command substitution because tee is used, but stdout does + # not). + # shellcheck disable=SC2327,SC2328 errors=$("${@}" $INITRD >(tee /dev/stderr) > /dev/fd/$stdout) ret=$? exec {stdout}>&- @@ -23,6 +28,10 @@ run_test_status () local stdout ret exec {stdout}>&1 + # SC complains that redirection without tee takes output way from + # command substitution, but that is what we want here (tee is used + # inside the parenthesis). + # shellcheck disable=SC2327,SC2328 lines=$(run_test "$@" > >(tee /dev/fd/$stdout)) ret=$? exec {stdout}>&- diff --git a/scripts/runtime.bash b/scripts/runtime.bash index 289e52bb..12ac0f38 100644 --- a/scripts/runtime.bash +++ b/scripts/runtime.bash @@ -190,6 +190,12 @@ function run() # qemu_params/extra_params in the config file may contain backticks that # need to be expanded, so use eval to start qemu. Use "> >(foo)" instead of # a pipe to preserve the exit status. + # + # SC complains that redirection without tee takes output way from command + # substitution, but that is what we want here (tee is used inside the + # parenthesis and output piped to extract_summary which is captured by + # command substitution). + # shellcheck disable=SC2327,SC2328 summary=$(eval "$cmdline" 2> >(RUNTIME_log_stderr $testname) \ > >(tee >(RUNTIME_log_stdout $testname $kernel) | extract_summary)) ret=$? -- 2.51.0