Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH v2] [pre-commit] Add shellcheck
Date: Fri, 19 Jun 2026 13:23:07 +0200	[thread overview]
Message-ID: <20260619112307.138647-1-tdevries@suse.de> (raw)

I found a pure python implementation of shellcheck [1][2].

It's not an exact copy, but close enough.  One notable difference is the
absence of data flow analysis [3], so basically it's got a hardcoded
--extended-analysis=false.

I've done a security audit using Claude Sonnet 4.5 with the prompts:
...
/security-review
Please do the security review for the source code.
...
and that seemed fine.

Use it to check scripts in the repo.

Exclude any scripts that are not currently clean.

As an example, gdb/testsuite/make-check-all.sh is shellcheck clean, but not
with --extended-analysis=false:
...
$ shellcheck --extended-analysis=true make-check-all.sh >/dev/null; echo $?
0
$ shellcheck --extended-analysis=false make-check-all.sh >/dev/null; echo $?
1
...
so it's also excluded.

Running it seems reasonably fast:
...
$ pre-commit run pureshellcheck --all-files -v
pureshellcheck..........................................................Passed
- hook id: pureshellcheck
- duration: 0.06s
...

For information on other solutions, see this RFC [4].

Changes in v2:
- mention hardcoded --extended-analysis=false
- mention security audit
- use commit hash to pin down version, for now via a clone (as we've done
  before with tclint) because the official source doesn't contain a
  .pre-commit-hooks.yaml file

Versions:
- v1 https://sourceware.org/pipermail/gdb-patches/2026-June/228118.html

[1] https://pypi.org/project/pureshellcheck/0.2.2/
[2] https://github.com/adam2go/pureshellcheck
[3] https://github.com/adam2go/pureshellcheck/issues/1
[4] https://sourceware.org/pipermail/gdb-patches/2024-November/213400.html
---
 .pre-commit-config.yaml | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 9910bbb82f2..af2fd6403e0 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -94,6 +94,21 @@ repos:
       args: [--trust-plugins]
       files: '^gdb/testsuite/.*\.(exp|tcl)$'
 
+  # Pureshellcheck hooks.  The repo is a clone of pureshellcheck
+  # ( https://github.com/adam2go/pureshellcheck ), with a
+  # .pre-commit-hooks.yaml file added.  Use a commit hash rather than a tag to
+  # guard against supply chain attacks.
+  - repo: https://github.com/vries/pureshellcheck
+    # The commit hash corresponds to v0.2.2, that is:
+    # $ git diff --stat v0.2.2 <rev>
+    # .pre-commit-hooks.yaml | 5 +++++
+    rev: a41d65d3a941325e6cb901e60b0a7e7975d1fb64
+    hooks:
+    - id: pureshellcheck
+      files: '^(gdb|gdbsupport|gdbserver)/'
+      types: ['shell']
+      exclude: '^(gdb/config/djgpp/(djcheck.sh|djconfig.sh)|gdb/contrib/ari/(create-web-ari-in-src.sh|gdb_ari.sh|update-web-ari.sh)|gdb/contrib/(cc-with-tweaks.sh|expect-read1.sh|gdb-add-index.sh|license-check-new-files.sh)|gdb/gdb_buildall.sh|gdb/gdb_mbuild.sh|gdb/regformats/regdat.sh|gdb/syscalls/update-linux-from-src.sh|gdb/testsuite/make-check-all.sh|gdb/gcore-1.in|gdb/po/gdbtext|gdb/testsuite/lib/pdtrace.in)$|/configure$'
+
   # Local hooks.
   - repo: local
     hooks:

base-commit: fd3cf86c638b7fdc0ccb64e178ec43ccd7e9d3f9
-- 
2.51.0


                 reply	other threads:[~2026-06-19 11:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260619112307.138647-1-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /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