Skip to content

Commit ed4c42d

Browse files
committed
test(ci): run suite under bash 4+ (re-exec + install in CI)
- tests/run.sh: re-exec into Homebrew bash when invoked under bash <4 (macOS /bin/bash is 3.2; suite exercises nameref/assoc-array code that needs 4+), mirroring macrift.sh's guard - ci.yml: brew install bash so the runner has bash 4+ at the re-exec path
1 parent 954b153 commit ed4c42d

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v5
1515

16-
- name: Install ShellCheck
17-
run: brew install shellcheck
16+
- name: Install ShellCheck & bash 4+
17+
run: brew install shellcheck bash
1818

1919
- name: ShellCheck
2020
run: |

tests/run.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@
66
# from it can never silently drift from the intended set (the casing bug that
77
# started this work lived in the old hand-synced parallel arrays).
88

9+
# macrift requires bash 4+ (namerefs, associative arrays) and re-execs into it
10+
# at runtime; the suite exercises that code, so it must run under bash 4+ too.
11+
# macOS ships bash 3.2 as /bin/bash — re-exec into Homebrew bash when invoked
12+
# under an older one (mirrors macrift.sh's guard).
13+
if [[ "${BASH_VERSION%%.*}" -lt 4 ]]; then
14+
for _newer in /opt/homebrew/bin/bash /usr/local/bin/bash; do
15+
[[ -x "$_newer" ]] && exec "$_newer" "$0" "$@"
16+
done
17+
printf 'tests/run.sh requires bash 4+ (found %s) — run: brew install bash\n' "$BASH_VERSION" >&2
18+
exit 1
19+
fi
20+
921
set -uo pipefail
1022

1123
ROOT="$(cd "$(dirname "$0")/.." && pwd)"

0 commit comments

Comments
 (0)