From 408eef8a0fe0cbfef5c25fb272ce819b6b34a322 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Sun, 30 Aug 2026 09:50:12 +0200 Subject: [PATCH] fix(lint): make the Unicode-space regex actually match Unicode spaces (#3027) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `Lint workflows` autofix job has failed on every scheduled run since at least 2026-08-16, with `shfmt` reporting parse errors ("LitWord cannot be followed by a word", "${ stmts;} is a mksh feature", ...) in ~70 shell scripts that parse cleanly on a pristine checkout. Root cause is the preceding "Fix non-printable Unicode spaces" step. Its regex was written as `$'[\\u00A0\\u2002...]'`: the doubled backslash makes bash's ANSI-C quoting emit the literal text ` `, and Perl has no `\u` codepoint escape — `\u` is the titlecase-next-character operator, so the character class degrades to the plain characters `0 2 3 5 7 8 9 A B F`. The step therefore replaced those digits and letters with spaces in every text file in the repo, which is what left the shell scripts unparseable. `shfmt` then exited 1 and the job stopped before opening its autofix PR — the only reason the corruption was never committed. Switch to Perl's own `\x{...}` escape in a plain single-quoted string, so the class holds the ten intended code points and nothing else. Verified locally against the exact step body extracted from the workflow: on a sample of the repo it now rewrites only the real U+202F occurrences (e.g. `postgres_15/.../99-run.sh`, `birdnet-pi/DOCS.md`) and leaves all other text untouched, and `shfmt v3.12.0 -w -i 4 -ci -bn -sr` over the whole repo exits 0 with no parse errors. Co-authored-by: Claude Opus 5 --- .github/workflows/lint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 523c2b200f..096cb8fb7b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -38,7 +38,7 @@ jobs: run: | set -euo pipefail CHANGED_FILES=$(git diff --name-only "$DIFF_RANGE") - UNICODE_SPACES_REGEX=$'[\\u00A0\\u2002\\u2003\\u2007\\u2008\\u2009\\u202F\\u205F\\u3000\\u200B]' + UNICODE_SPACES_REGEX='[\x{00A0}\x{2002}\x{2003}\x{2007}\x{2008}\x{2009}\x{202F}\x{205F}\x{3000}\x{200B}]' for file in $CHANGED_FILES; do if [ -f "$file" ]; then MIME_TYPE=$(file --mime-type -b "$file") @@ -89,7 +89,7 @@ jobs: - name: Fix non-printable Unicode spaces in all text files run: | set -euo pipefail - UNICODE_SPACES_REGEX=$'[\\u00A0\\u2002\\u2003\\u2007\\u2008\\u2009\\u202F\\u205F\\u3000\\u200B]' + UNICODE_SPACES_REGEX='[\x{00A0}\x{2002}\x{2003}\x{2007}\x{2008}\x{2009}\x{202F}\x{205F}\x{3000}\x{200B}]' find . -type f ! -path "./.git/*" | while read -r file; do MIME_TYPE=$(file --mime-type -b "$file") if [[ "$MIME_TYPE" == text/* ]]; then