From: Andrew Jones <andrew.jones@linux.dev>
To: Nicholas Piggin <npiggin@gmail.com>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Thomas Huth" <thuth@redhat.com>,
"Alexandru Elisei" <alexandru.elisei@arm.com>,
"Eric Auger" <eric.auger@redhat.com>,
"Janosch Frank" <frankja@linux.ibm.com>,
"Claudio Imbrenda" <imbrenda@linux.ibm.com>,
"Nico Böhr" <nrb@linux.ibm.com>,
"David Hildenbrand" <david@redhat.com>,
"Shaoqin Huang" <shahuang@redhat.com>,
"Nikos Nikoleris" <nikos.nikoleris@arm.com>,
"Nadav Amit" <namit@vmware.com>,
"David Woodhouse" <dwmw@amazon.co.uk>,
"Ricardo Koller" <ricarkol@google.com>,
rminmin <renmm6@chinaunicom.cn>, "Gavin Shan" <gshan@redhat.com>,
"Nina Schoetterl-Glausch" <nsg@linux.ibm.com>,
"Sean Christopherson" <seanjc@google.com>,
kvm@vger.kernel.org, kvmarm@lists.linux.dev,
kvm-riscv@lists.infradead.org, linux-s390@vger.kernel.org
Subject: Re: [kvm-unit-tests RFC PATCH 01/17] Add initial shellcheck checking
Date: Fri, 5 Apr 2024 16:12:13 +0200 [thread overview]
Message-ID: <20240405-4880f3f2b12bcae5f3383043@orel> (raw)
In-Reply-To: <20240405090052.375599-2-npiggin@gmail.com>
On Fri, Apr 05, 2024 at 07:00:33PM +1000, Nicholas Piggin wrote:
> This adds a basic shellcheck sytle file, some directives to help
> find scripts, and a make shellcheck target.
>
> When changes settle down this could be made part of the standard
> build / CI flow.
>
> Suggested-by: Andrew Jones <andrew.jones@linux.dev>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
> .shellcheckrc | 32 ++++++++++++++++++++++++++++++++
> Makefile | 4 ++++
> README.md | 2 ++
> scripts/common.bash | 5 ++++-
> 4 files changed, 42 insertions(+), 1 deletion(-)
> create mode 100644 .shellcheckrc
>
> diff --git a/.shellcheckrc b/.shellcheckrc
> new file mode 100644
> index 000000000..2a9a57c42
> --- /dev/null
> +++ b/.shellcheckrc
> @@ -0,0 +1,32 @@
> +# shellcheck configuration file
> +external-sources=true
> +
> +# Optional extras -- https://www.shellcheck.net/wiki/Optional
> +# Possibilities, e.g., -
> +# quote‐safe‐variables
> +# require-double-brackets
> +# require-variable-braces
> +# add-default-case
> +
> +# Disable SC2004 style? I.e.,
> +# In run_tests.sh line 67:
> +# if (( $unittest_run_queues <= 0 )); then
> +# ^------------------^ SC2004 (style): $/${} is unnecessary on arithmetic variables.
> +disable=SC2004
I vote keep disabled. The problem pointed out in the wiki can be handled
with ($a), similar to how one handles variables to C preprocessor macros.
> +
> +# Disable SC2034 - config.mak contains a lot of these unused variable errors.
> +# Maybe we could have a script extract the ones used by shell script and put
> +# them in a generated file, to re-enable the warning.
> +#
> +# In config.mak line 1:
> +# SRCDIR=/home/npiggin/src/kvm-unit-tests
> +# ^----^ SC2034 (warning): SRCDIR appears unused. Verify use (or export if used externally).
> +disable=SC2034
Maybe we should export everything in config.mak.
> +
> +# Disable SC2086 for now, double quote to prevent globbing and word
> +# splitting. There are lots of places that use it for word splitting
> +# (e.g., invoking commands with arguments) that break. Should have a
> +# more consistent approach for this (perhaps use arrays for such cases)
> +# but for now disable.
> +# SC2086 (info): Double quote to prevent globbing and word splitting.
> +disable=SC2086
Agreed. We can cross this bridge later.
> diff --git a/Makefile b/Makefile
> index 4e0f54543..4863cfdc6 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -141,6 +141,10 @@ cscope:
> -name '*.[chsS]' -exec realpath --relative-base=$(CURDIR) {} \; | sort -u > ./cscope.files
> cscope -bk
>
> +.PHONY: shellcheck
> +shellcheck:
> + shellcheck -a run_tests.sh */run */efi/run scripts/mkstandalone.sh
> +
> .PHONY: tags
> tags:
> ctags -R
> diff --git a/README.md b/README.md
> index 6e82dc225..77718675e 100644
> --- a/README.md
> +++ b/README.md
> @@ -193,3 +193,5 @@ with `git config diff.orderFile scripts/git.difforder` enables it.
>
> We strive to follow the Linux kernels coding style so it's recommended
> to run the kernel's ./scripts/checkpatch.pl on new patches.
> +
> +Also run make shellcheck before submitting a patch.
which touches Bash scripts.
> diff --git a/scripts/common.bash b/scripts/common.bash
> index ee1dd8659..3aa557c8c 100644
> --- a/scripts/common.bash
> +++ b/scripts/common.bash
> @@ -82,8 +82,11 @@ function arch_cmd()
> }
>
> # The current file has to be the only file sourcing the arch helper
> -# file
> +# file. Shellcheck can't follow this so help it out. There doesn't appear to be a
> +# way to specify multiple alternatives, so we will have to rethink this if things
> +# get more complicated.
> ARCH_FUNC=scripts/${ARCH}/func.bash
> if [ -f "${ARCH_FUNC}" ]; then
> +# shellcheck source=scripts/s390x/func.bash
> source "${ARCH_FUNC}"
> fi
> --
> 2.43.0
>
Other than the extension to the sentence in the README,
Reviewed-by: Andrew Jones <andrew.jones@linux.dev>
Thanks,
drew
next prev parent reply other threads:[~2024-04-05 14:12 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-05 9:00 [kvm-unit-tests RFC PATCH 00/17] add shellcheck support Nicholas Piggin
2024-04-05 9:00 ` [kvm-unit-tests RFC PATCH 01/17] Add initial shellcheck checking Nicholas Piggin
2024-04-05 14:12 ` Andrew Jones [this message]
2024-04-06 6:39 ` Nicholas Piggin
2024-04-05 9:00 ` [kvm-unit-tests RFC PATCH 02/17] shellcheck: Fix SC2223 Nicholas Piggin
2024-04-05 14:14 ` Andrew Jones
2024-04-05 9:00 ` [kvm-unit-tests RFC PATCH 03/17] shellcheck: Fix SC2295 Nicholas Piggin
2024-04-05 14:15 ` Andrew Jones
2024-04-05 9:00 ` [kvm-unit-tests RFC PATCH 04/17] shellcheck: Fix SC2094 Nicholas Piggin
2024-04-05 14:17 ` Andrew Jones
2024-04-05 9:00 ` [kvm-unit-tests RFC PATCH 05/17] shellcheck: Fix SC2006 Nicholas Piggin
2024-04-05 14:17 ` Andrew Jones
2024-04-05 9:00 ` [kvm-unit-tests RFC PATCH 06/17] shellcheck: Fix SC2155 Nicholas Piggin
2024-04-05 14:20 ` Andrew Jones
2024-04-05 9:00 ` [kvm-unit-tests RFC PATCH 07/17] shellcheck: Fix SC2235 Nicholas Piggin
2024-04-05 14:24 ` Andrew Jones
2024-04-06 6:41 ` Nicholas Piggin
2024-04-05 9:00 ` [kvm-unit-tests RFC PATCH 08/17] shellcheck: Fix SC2119, SC2120 Nicholas Piggin
2024-04-05 14:28 ` Andrew Jones
2024-04-05 9:00 ` [kvm-unit-tests RFC PATCH 09/17] shellcheck: Fix SC2143 Nicholas Piggin
2024-04-05 14:29 ` Andrew Jones
2024-04-05 9:00 ` [kvm-unit-tests RFC PATCH 10/17] shellcheck: Fix SC2013 Nicholas Piggin
2024-04-05 14:31 ` Andrew Jones
2024-04-05 9:00 ` [kvm-unit-tests RFC PATCH 11/17] shellcheck: Fix SC2145 Nicholas Piggin
2024-04-05 14:35 ` Andrew Jones
2024-04-06 6:47 ` Nicholas Piggin
2024-04-05 9:00 ` [kvm-unit-tests RFC PATCH 12/17] shellcheck: Fix SC2124 Nicholas Piggin
2024-04-05 14:37 ` Andrew Jones
2024-04-05 9:00 ` [kvm-unit-tests RFC PATCH 13/17] shellcheck: Fix SC2294 Nicholas Piggin
2024-04-05 14:38 ` Andrew Jones
2024-04-05 9:00 ` [kvm-unit-tests RFC PATCH 14/17] shellcheck: Fix SC2178 Nicholas Piggin
2024-04-05 14:40 ` Andrew Jones
2024-04-05 9:00 ` [kvm-unit-tests RFC PATCH 15/17] shellcheck: Fix SC2048 Nicholas Piggin
2024-04-05 14:40 ` Andrew Jones
2024-04-05 9:00 ` [kvm-unit-tests RFC PATCH 16/17] shellcheck: Fix SC2153 Nicholas Piggin
2024-04-05 14:42 ` Andrew Jones
2024-04-05 9:00 ` [kvm-unit-tests RFC PATCH 17/17] shellcheck: Suppress various messages Nicholas Piggin
2024-04-05 14:55 ` Andrew Jones
2024-04-06 6:31 ` Nicholas Piggin
2024-04-06 7:30 ` Andrew Jones
2024-04-06 10:56 ` Nicholas Piggin
2024-04-05 13:59 ` [kvm-unit-tests RFC PATCH 00/17] add shellcheck support Andrew Jones
2024-04-06 6:34 ` 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=20240405-4880f3f2b12bcae5f3383043@orel \
--to=andrew.jones@linux.dev \
--cc=alexandru.elisei@arm.com \
--cc=david@redhat.com \
--cc=dwmw@amazon.co.uk \
--cc=eric.auger@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=gshan@redhat.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm-riscv@lists.infradead.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-s390@vger.kernel.org \
--cc=namit@vmware.com \
--cc=nikos.nikoleris@arm.com \
--cc=npiggin@gmail.com \
--cc=nrb@linux.ibm.com \
--cc=nsg@linux.ibm.com \
--cc=pbonzini@redhat.com \
--cc=renmm6@chinaunicom.cn \
--cc=ricarkol@google.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