From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id a41rBvrpj2qwWgUAWB0awg (envelope-from ) for ; Thu, 27 Aug 2026 03:40:42 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=oW3XPXpm; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=+23Dmqiw; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=ggIXySZm; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=FyI3E3W/; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id E4EAA1E09B; Thu, 27 Aug 2026 03:40:41 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id E37301E09B for ; Thu, 27 Aug 2026 03:40:38 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C34704BA79B4 for ; Thu, 27 Aug 2026 07:40:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C34704BA79B4 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=oW3XPXpm; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=+23Dmqiw; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=ggIXySZm; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=FyI3E3W/ Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id A98E04BA2E19 for ; Thu, 27 Aug 2026 07:40:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A98E04BA2E19 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A98E04BA2E19 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1787816411; cv=none; b=Dp7aW8K11jfRXIKyarEKIedF19EdZuwHxoQm7qlWP7IZ6hJOlpyzamuFn3wk6RGw8lX+aZihjFu3wIYpGgpzZpKYap028i+WfYjuYvYwg3yIBXk+UojdMi1CNT4NknVG5LHEccjl2KLlWt+JvdT2QvaOTFTCOem7H3ZF3ad/gzs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1787816411; c=relaxed/simple; bh=v0pKf5+sra/Jg0+9P4yb6jgTOjepPp2vxurPBQsH+VE=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:From:To; b=O/7lEmbV0NOv6UkenowRtP9SWYUZpg7nP70T9OkIIbI4ZLKlbvzdG0Qcc2BNTK668qE4fyYTtIa7/fOQllshERnlEq7sEpYZXRK0aN3tSoEgbxVvT87yOWx3esd8Lha3xJ+MAsA3buYEr3lNhFXaMsI20mOZZq9p+wOsE9vSTvo= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=oW3XPXpm; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=+23Dmqiw; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=ggIXySZm; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=FyI3E3W/ DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A98E04BA2E19 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 89DA5216EE for ; Thu, 27 Aug 2026 07:40:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787816406; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RSB7x5KBt5jHBbcvH6wpPCGQlN79ij8Oh37EHbuE+9g=; b=oW3XPXpmFDS0PPxMRmT4bn3+K8rpPZnxQACLcdEbVOu9Jee5LK5T3yp8cmP6DXnJ7maZYx C9sZ8E5Z4ieTltk2m/NaQXAsgyBkucZsXlXSDzgQyqMuv1YJcFoINoPw2o8ZzuJOhlhmBl TwIm+q42BOI1eB/HLVVhP6y9pSgadhM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787816406; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RSB7x5KBt5jHBbcvH6wpPCGQlN79ij8Oh37EHbuE+9g=; b=+23Dmqiw64uerzeqZbaWDMHOZt11a/EFBXkT9YBGj3RbATt8ctCAFi98buUCz6vS3YSIRE xuXG7x9yCe516vAQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787816402; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RSB7x5KBt5jHBbcvH6wpPCGQlN79ij8Oh37EHbuE+9g=; b=ggIXySZm8adHEVu0H00hfKtlmRyGrulRn+LwgwFsHF7e2livYiB6dUdoyVyBGSrKhMVHEY bdiRfNpd+a/HnG+5fPLk4Xcorxl1j73jNwzOqRAFqW9FbYc3RO7+BU5fKK/1Cad6JH0I/b Mwqu3/7Hd8bHQdFmUG4AOb5hWvfDR4w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787816402; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RSB7x5KBt5jHBbcvH6wpPCGQlN79ij8Oh37EHbuE+9g=; b=FyI3E3W/IS/ZS3OJBSSP2Zs4D48gOHzQK7HXV/0A7oD4w2X/XyEYxVwxurYBRnsvbfuBx3 +8J1fCjFLovd2bDw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 797F313354 for ; Thu, 27 Aug 2026 07:40:02 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id Ep5JHNLpj2p7DAAAD6G6ig (envelope-from ) for ; Thu, 27 Aug 2026 07:40:02 +0000 Message-ID: <6f12c448-2e14-4736-b103-5d540a64fe4c@suse.de> Date: Thu, 27 Aug 2026 09:40:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] [pre-commit] Add shellcheck From: Tom de Vries To: gdb-patches@sourceware.org References: <20260730123539.24766-1-tdevries@suse.de> Content-Language: en-US In-Reply-To: <20260730123539.24766-1-tdevries@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-0.996]; MIME_GOOD(-0.10)[text/plain]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; FROM_EQ_ENVFROM(0.00)[]; TO_DN_NONE(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+] X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 7/30/26 2:35 PM, Tom de Vries wrote: > Add a pre-commit shellcheck hook. > > Contrary to a usual pre-commit setup, users are expected to provide shellcheck > themselves. > > Since that can be non-trival, as a compromise both versions 0.11.0 and 0.10.0 > are allowed. > I've pushed this, with some last-minute changes: - fixing review comments from Claude Code: added set -e, added some quoting - set stages to manual. This makes it opt-in, and normal pre-commit usage shouldn't be disturbed, handling the case that someone doesn't have (an allowed version of) shellcheck installed more gracefully Running all hooks now becomes: ... $ for hs in pre-commit manual; do \ pre-commit run --hook-stage $hs --all-files; \ done ... Thanks, - Tom > This can lead to "but it works for me" situations, but people not using it > because they don't have the latest version available seems worse. > > If version 0.10.0 is used, a note is emitted, though this is only visible > with -v: > .... > $ pre-commit run shellcheck --all-files -v > shellcheck...............................................................Passed > - hook id: shellcheck > - duration: 0.13s > > Using shellcheck version 0.10.0, but version 0.11.0 is preferred. > ... > Using shellcheck version 0.10.0, but version 0.11.0 is preferred. > ... > > Alternative solutions are: > - pureshellcheck [1]. Python, but the project seems unmaintained. > - shellcheck-py [2]. Downloads an executable and runs it. > - shellcheck-precommit [3]. Downloads a docker image and runs it. > > Changes in v3: > - abandoned pureshellcheck approach used in v1 and v2. > > Versions: > - v2 https://sourceware.org/pipermail/gdb-patches/2026-June/228145.html > - v1 https://sourceware.org/pipermail/gdb-patches/2026-June/228118.html > > [1] https://github.com/adam2go/pureshellcheck > [2] https://github.com/shellcheck-py/shellcheck-py > [3] https://github.com/koalaman/shellcheck-precommit > --- > .pre-commit-config.yaml | 10 ++++++ > gdb/contrib/shellcheck.sh | 65 +++++++++++++++++++++++++++++++++++++++ > 2 files changed, 75 insertions(+) > create mode 100755 gdb/contrib/shellcheck.sh > > diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml > index 8ff84dae274..75eb1edd11d 100644 > --- a/.pre-commit-config.yaml > +++ b/.pre-commit-config.yaml > @@ -147,3 +147,13 @@ repos: > language: unsupported_script > entry: gdb/contrib/check-file-mode.sh > files: *gdb_files > + - id: &id5 shellcheck > + name: *id5 > + files: '^(gdb|gdbsupport|gdbserver)/' > + types: ['shell'] > + language: unsupported_script > + # The gdb/contrib/shellcheck.sh script requires shellcheck 0.11.0 > + # (preferred) or 0.10.0. Not pinning this to a single version is a > + # compromise to deal with the fact that users themselves need to > + # provide the dependency, which may be non-trivial. > + entry: gdb/contrib/shellcheck.sh > diff --git a/gdb/contrib/shellcheck.sh b/gdb/contrib/shellcheck.sh > new file mode 100755 > index 00000000000..259988bec48 > --- /dev/null > +++ b/gdb/contrib/shellcheck.sh > @@ -0,0 +1,65 @@ > +#!/bin/bash > + > +# Copyright (C) 2026 Free Software Foundation, Inc. > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 3 of the License, or > +# (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. If not, see . > + > +version=$(shellcheck --version | grep ^version | awk '{print $2}') > + > +case "$version" in > + 0.11.0) > + # Preferred version. > + true > + ;; > + 0.10.0) > + # Allowed version, but mention preferred version. This will be > + # visible with "pre-commit run shellcheck --all-files -v". > + echo "Using shellcheck version 0.10.0, but version 0.11.0 is preferred." > + ;; > + *) > + echo "Please install shellcheck version 0.11.0 (preferred) or 0.10.0" > + exit 1 > + ;; > +esac > + > +files=() > +for f in "$@"; do > + case "$f" in > + */configure) > + # Skip generated files. > + continue > + ;; > + gdb/config/djgpp/djcheck.sh \ > + | gdb/config/djgpp/djconfig.sh \ > + | gdb/contrib/cc-with-tweaks.sh \ > + | gdb/contrib/gdb-add-index.sh \ > + | gdb/gdb_buildall.sh \ > + | gdb/gdb_mbuild.sh \ > + | gdb/po/gdbtext \ > + | gdb/regformats/regdat.sh \ > + | gdb/testsuite/lib/pdtrace.in) > + # Skip unclean files. > + continue > + ;; > + *) > + files=("${files[@]}" "$f") > + ;; > + esac > +done > + > +if [ ${#files[@]} -eq 0 ]; then > + # Nothing to do. > + exit 0 > +fi > + > +shellcheck "${files[@]}" > > base-commit: 0d22d419a4b60672acf5555f5479fcf6956018a1