From: Andrew Jones <andrew.jones@linux.dev>
To: Nicholas Piggin <npiggin@gmail.com>
Cc: kvm@vger.kernel.org, Shaoqin Huang <shahuang@redhat.com>,
Alexandru Elisei <alexandru.elisei@arm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
Thomas Huth <thuth@redhat.com>,
Sean Christopherson <seanjc@google.com>,
kvm-riscv@lists.infradead.org, Joel Stanley <joel@jms.id.au>
Subject: Re: [PATCH 2/2] shellcheck: suppress SC2327,2328 false positives
Date: Mon, 8 Sep 2025 13:23:35 -0500 [thread overview]
Message-ID: <20250908-d271d19e8179dae99c23143f@orel> (raw)
In-Reply-To: <20250908010618.440178-2-npiggin@gmail.com>
On Mon, Sep 08, 2025 at 11:06:18AM +1000, Nicholas Piggin wrote:
> 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 <npiggin@gmail.com>
> ---
> 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
s/way/away/
Same comment for the other uses below.
> + # 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 </dev/null 2> >(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
Changed way to away while merging.
Thanks,
drew
--
kvm-riscv mailing list
kvm-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscv
next prev parent reply other threads:[~2025-09-09 2:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-08 1:06 [PATCH 1/2] build: work around secondary expansion limitation with some Make versions Nicholas Piggin
2025-09-08 1:06 ` [PATCH 2/2] shellcheck: suppress SC2327,2328 false positives Nicholas Piggin
2025-09-08 18:23 ` Andrew Jones [this message]
2025-09-08 18:22 ` [PATCH 1/2] build: work around secondary expansion limitation with some Make versions Andrew Jones
2025-09-08 23:23 ` Nicholas Piggin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250908-d271d19e8179dae99c23143f@orel \
--to=andrew.jones@linux.dev \
--cc=alexandru.elisei@arm.com \
--cc=imbrenda@linux.ibm.com \
--cc=joel@jms.id.au \
--cc=kvm-riscv@lists.infradead.org \
--cc=kvm@vger.kernel.org \
--cc=npiggin@gmail.com \
--cc=seanjc@google.com \
--cc=shahuang@redhat.com \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).