From 6c32291c32ac9db7b3b12f408af3e82971aa8a2c Mon Sep 17 00:00:00 2001 From: Howon Lee Date: Wed, 28 Oct 2026 15:46:03 -0700 Subject: [PATCH] fix: restore Bash 3.2 startup compatibility (12106) --- .github/workflows/lint.yml | 20 ++++++++++++++++++++ lib/commands/init.sh | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8d377d0..6d5d289 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -36,6 +36,26 @@ jobs: - name: Verify completion files are up to date run: ./scripts/generate-completions.sh --check + bash-compatibility: + name: macOS Bash 3.2 + runs-on: macos-latest + steps: + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + with: + persist-credentials: false + + - name: Exercise CLI startup and shell integration with system Bash + shell: /bin/bash --noprofile --norc -eo pipefail {0} + run: | + export PATH="$PWD/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH" + export XDG_CACHE_HOME="$RUNNER_TEMP/gtr-cache" + /bin/bash --version + git gtr --version + ./bin/gtr --version + git gtr init bash > "$RUNNER_TEMP/gtr-init.bash" + /bin/bash -n "$RUNNER_TEMP/gtr-init.bash" + source "$RUNNER_TEMP/gtr-init.bash" + test: name: Tests runs-on: ubuntu-latest diff --git a/lib/commands/init.sh b/lib/commands/init.sh index 77e75b3..96f9521 100644 --- a/lib/commands/init.sh +++ b/lib/commands/init.sh @@ -135,6 +135,7 @@ _init_emit_posix_trust_helpers() { # Keep the snapshot encoding and extraction identical to the CLI. _init_emit_snapshot_helpers + # Keep case patterns balanced inside this substitution for Bash 3.2's parser. template=$(cat <<'EOF' __FUNC___gtrconfig_path() { __SHELL_PRELUDE__ @@ -186,7 +187,7 @@ __SHELL_PRELUDE__ _gtr_birth_time="${_gtr_identity#*:*:}" _gtr_birth_time="${_gtr_birth_time%%:*}" case "$_gtr_birth_time" in - ''|0|0.*|*[!0-9.]*) return 1 ;; + (''|0|0.*|*[!0-9.]*) return 1 ;; esac printf '%s\n%s\n' "$_gtr_common_dir" "$_gtr_identity" }