fortrangoingonforty/fortsh / c85cb6d

Browse files

use configurable BASH_REF for reference shell in all test suites

macOS ships bash 3.2 which lacks assoc arrays, case transforms, declare -g,
coproc, etc. Tests compared against bash 3.2 produced false failures. All test
files now use BASH_REF (defaults to bash) so CI can point to a modern bash.
Authored by espadonne
SHA
c85cb6de6c1eceecd491f7423872df6374b6e6ae
Parents
4c5bea2
Tree
f93355a

19 changed files

StatusFile+-
M tests/builtins/test_declare.sh 1 1
M tests/builtins/test_export_unset.sh 4 4
M tests/builtins/test_harness.sh 7 3
M tests/posix_compliance_advanced.sh 3 2
M tests/posix_compliance_control.sh 2 1
M tests/posix_compliance_coverage.sh 3 2
M tests/posix_compliance_extended.sh 3 2
M tests/posix_compliance_gaps.sh 4 3
M tests/posix_compliance_options.sh 2 1
M tests/posix_compliance_test.sh 3 2
M tests/posix_compliance_untested.sh 3 2
M tests/posix_gaps_arithmetic.sh 3 2
M tests/posix_gaps_builtins.sh 4 3
M tests/posix_gaps_charclass.sh 2 1
M tests/posix_gaps_control.sh 3 2
M tests/posix_gaps_heredoc.sh 3 2
M tests/posix_gaps_quoting.sh 2 1
M tests/posix_gaps_redirect.sh 3 2
M tests/posix_gaps_special.sh 2 1
tests/builtins/test_declare.shmodified
@@ -6,7 +6,7 @@ section "1. declare basic flags"
66
 compare_output "declare -i integer arithmetic" 'declare -i num=5+3; echo $num'
77
 compare_output "declare -r is readonly" 'declare -r RO=hello; echo $RO'
88
 compare_exit "declare -r prevents modification" 'declare -r RO=hello; RO=world 2>/dev/null'
9
-compare_output "declare -x exports variable" 'declare -x MYEXP=exported; bash -c "echo \$MYEXP"'
9
+compare_output "declare -x exports variable" 'declare -x MYEXP=exported; '"$BASH_REF"' -c "echo \$MYEXP"'
1010
 compare_output "declare plain variable" 'declare V=hello; echo $V'
1111
 
1212
 section "2. declare arrays"
tests/builtins/test_export_unset.shmodified
@@ -4,13 +4,13 @@ TEST_PREFIX="[export-unset]"
44
 
55
 section "1. export"
66
 compare_output "export VAR=value" 'export MYVAR=hello; echo $MYVAR'
7
-compare_output "export preserves in subshell" 'export MYVAR=hello; bash -c "echo \$MYVAR"'
8
-compare_output "export without value marks for export" 'MYVAR=test; export MYVAR; bash -c "echo \$MYVAR"'
7
+compare_output "export preserves in subshell" 'export MYVAR=hello; '"$BASH_REF"' -c "echo \$MYVAR"'
8
+compare_output "export without value marks for export" 'MYVAR=test; export MYVAR; '"$BASH_REF"' -c "echo \$MYVAR"'
99
 compare_output "export multiple vars" 'export A=1 B=2 C=3; echo $A $B $C'
1010
 compare_exit "export -p succeeds" 'export -p'
1111
 compare_output "export overwrites existing" 'export V=old; export V=new; echo $V'
12
-compare_output "unexported var not in subshell" 'MYVAR=local; bash -c "echo \${MYVAR:-empty}"'
13
-compare_output "export -n unexports variable" 'export MYVAR=hello; export -n MYVAR; bash -c "echo \${MYVAR:-gone}"'
12
+compare_output "unexported var not in subshell" 'MYVAR=local; '"$BASH_REF"' -c "echo \${MYVAR:-empty}"'
13
+compare_output "export -n unexports variable" 'export MYVAR=hello; export -n MYVAR; '"$BASH_REF"' -c "echo \${MYVAR:-gone}"'
1414
 
1515
 section "2. unset"
1616
 compare_output "unset removes variable" 'MYVAR=hello; unset MYVAR; echo ">${MYVAR}<"'
tests/builtins/test_harness.shmodified
@@ -47,6 +47,10 @@ FAILED_TESTS_LIST=""
4747
 SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
4848
 FORTSH_BIN="${FORTSH_BIN:-$SCRIPT_DIR/../../bin/fortsh}"
4949
 
50
+# Reference bash for expected output — must be bash 4+ for assoc arrays, case transforms
51
+# macOS ships bash 3.2 which lacks these; override with BASH_REF=/opt/homebrew/bin/bash
52
+BASH_REF="${BASH_REF:-bash}"
53
+
5054
 # Check if fortsh exists
5155
 if [ ! -x "$FORTSH_BIN" ]; then
5256
     printf "${RED}ERROR${NC}: fortsh binary not found at $FORTSH_BIN\n"
@@ -101,7 +105,7 @@ TEST_TIMEOUT="${TEST_TIMEOUT:-10}"
101105
 # Helper: compare output against bash
102106
 compare_output() {
103107
     test_name="$1"; command="$2"
104
-    expected=$(run_with_timeout "$TEST_TIMEOUT" bash -c "$command" 2>&1)
108
+    expected=$(run_with_timeout "$TEST_TIMEOUT" "$BASH_REF" -c "$command" 2>&1)
105109
     actual=$(run_with_timeout "$TEST_TIMEOUT" "$FORTSH_BIN" -c "$command" 2>&1)
106110
     norm_expected=$(normalize_shell_name "$expected")
107111
     norm_actual=$(normalize_shell_name "$actual")
@@ -112,7 +116,7 @@ compare_output() {
112116
 # Helper: compare exit code only
113117
 compare_exit() {
114118
     test_name="$1"; command="$2"
115
-    run_with_timeout "$TEST_TIMEOUT" bash -c "$command" >/dev/null 2>&1; expected=$?
119
+    run_with_timeout "$TEST_TIMEOUT" "$BASH_REF" -c "$command" >/dev/null 2>&1; expected=$?
116120
     run_with_timeout "$TEST_TIMEOUT" "$FORTSH_BIN" -c "$command" >/dev/null 2>&1; actual=$?
117121
     if [ "$expected" = "$actual" ]; then pass "$test_name"
118122
     else fail "$test_name" "exit $expected" "exit $actual"; fi
@@ -121,7 +125,7 @@ compare_exit() {
121125
 # Helper: compare both output and exit code
122126
 compare_both() {
123127
     test_name="$1"; command="$2"
124
-    expected_out=$(run_with_timeout "$TEST_TIMEOUT" bash -c "$command" 2>&1); expected_exit=$?
128
+    expected_out=$(run_with_timeout "$TEST_TIMEOUT" "$BASH_REF" -c "$command" 2>&1); expected_exit=$?
125129
     actual_out=$(run_with_timeout "$TEST_TIMEOUT" "$FORTSH_BIN" -c "$command" 2>&1); actual_exit=$?
126130
     norm_expected=$(normalize_shell_name "$expected_out")
127131
     norm_actual=$(normalize_shell_name "$actual_out")
tests/posix_compliance_advanced.shmodified
@@ -36,6 +36,7 @@ FAILED_TESTS_LIST=""
3636
 # Get script directory (POSIX way)
3737
 SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
3838
 FORTSH_BIN="${FORTSH_BIN:-$SCRIPT_DIR/../bin/fortsh}"
39
+BASH_REF="${BASH_REF:-bash}"
3940
 
4041
 # Check if fortsh exists
4142
 if [ ! -x "$FORTSH_BIN" ]; then
@@ -94,7 +95,7 @@ compare_posix_output() {
9495
     fortsh_file="/tmp/posix_adv_$$_fortsh"
9596
 
9697
     # Run in POSIX shell (sh)
97
-    bash -c "$command" 2>&1 | normalize_output > "$posix_file" || true
98
+    "$BASH_REF" -c "$command" 2>&1 | normalize_output > "$posix_file" || true
9899
 
99100
     # Run in fortsh
100101
     "$FORTSH_BIN" -c "$command" 2>&1 | normalize_output > "$fortsh_file" || true
@@ -114,7 +115,7 @@ compare_posix_exit_code() {
114115
     test_name="$1"
115116
     command="$2"
116117
 
117
-    bash -c "$command" > /dev/null 2>&1
118
+    "$BASH_REF" -c "$command" > /dev/null 2>&1
118119
     posix_exit=$?
119120
 
120121
     "$FORTSH_BIN" -c "$command" > /dev/null 2>&1
tests/posix_compliance_control.shmodified
@@ -25,6 +25,7 @@ FAILED_TESTS_LIST=""
2525
 # Get script directory (POSIX way)
2626
 SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
2727
 FORTSH_BIN="${FORTSH_BIN:-$SCRIPT_DIR/../bin/fortsh}"
28
+BASH_REF="${BASH_REF:-bash}"
2829
 
2930
 # Check if fortsh exists
3031
 if [ ! -x "$FORTSH_BIN" ]; then
@@ -1143,7 +1144,7 @@ fi
11431144
 # Both bash and fortsh correctly treat this as arithmetic and error
11441145
 "$FORTSH_BIN" -c '((echo deep))' >/dev/null 2>&1
11451146
 fortsh_exit=$?
1146
-bash -c '((echo deep))' >/dev/null 2>&1
1147
+"$BASH_REF" -c '((echo deep))' >/dev/null 2>&1
11471148
 bash_exit=$?
11481149
 if [ "$fortsh_exit" -eq "$bash_exit" ]; then
11491150
     pass "double paren arithmetic exit"
tests/posix_compliance_coverage.shmodified
@@ -3,6 +3,7 @@
33
 # These tests cover edge cases and behaviors not covered by other test suites
44
 
55
 FORTSH_BIN="${FORTSH_BIN:-./bin/fortsh}"
6
+BASH_REF="${BASH_REF:-bash}"
67
 
78
 # Colors
89
 RED='\033[0;31m'
@@ -66,7 +67,7 @@ compare_posix_output() {
6667
     test_name="$1"
6768
     test_cmd="$2"
6869
 
69
-    posix_output=$(FORTSH_RC_FILE=/dev/null bash -c "$test_cmd" 2>&1 | normalize_output)
70
+    posix_output=$(FORTSH_RC_FILE=/dev/null "$BASH_REF" -c "$test_cmd" 2>&1 | normalize_output)
7071
     posix_exit=$?
7172
 
7273
     fortsh_output=$(FORTSH_RC_FILE=/dev/null "$FORTSH_BIN" -c "$test_cmd" 2>&1 | normalize_output)
@@ -90,7 +91,7 @@ compare_posix_error() {
9091
     test_name="$1"
9192
     test_cmd="$2"
9293
 
93
-    posix_output=$(FORTSH_RC_FILE=/dev/null bash -c "$test_cmd" 2>&1)
94
+    posix_output=$(FORTSH_RC_FILE=/dev/null "$BASH_REF" -c "$test_cmd" 2>&1)
9495
     posix_exit=$?
9596
 
9697
     fortsh_output=$(FORTSH_RC_FILE=/dev/null "$FORTSH_BIN" -c "$test_cmd" 2>&1)
tests/posix_compliance_extended.shmodified
@@ -25,6 +25,7 @@ FAILED_TESTS_LIST=""
2525
 # Get script directory (POSIX way)
2626
 SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
2727
 FORTSH_BIN="${FORTSH_BIN:-$SCRIPT_DIR/../bin/fortsh}"
28
+BASH_REF="${BASH_REF:-bash}"
2829
 
2930
 # Check if fortsh exists
3031
 if [ ! -x "$FORTSH_BIN" ]; then
@@ -78,7 +79,7 @@ compare_posix_output() {
7879
     fortsh_file="/tmp/posix_ext_$$_fortsh"
7980
 
8081
     # Run in POSIX shell (sh)
81
-    bash -c "$command" > "$posix_file" 2>&1 || true
82
+    "$BASH_REF" -c "$command" > "$posix_file" 2>&1 || true
8283
 
8384
     # Run in fortsh
8485
     "$FORTSH_BIN" -c "$command" > "$fortsh_file" 2>&1 || true
@@ -98,7 +99,7 @@ compare_posix_exit_code() {
9899
     test_name="$1"
99100
     command="$2"
100101
 
101
-    bash -c "$command" > /dev/null 2>&1
102
+    "$BASH_REF" -c "$command" > /dev/null 2>&1
102103
     posix_exit=$?
103104
 
104105
     "$FORTSH_BIN" -c "$command" > /dev/null 2>&1
tests/posix_compliance_gaps.shmodified
@@ -41,6 +41,7 @@ DEBUG_INFO=""
4141
 # Get script directory (POSIX way)
4242
 SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
4343
 FORTSH_BIN="${FORTSH_BIN:-$SCRIPT_DIR/../bin/fortsh}"
44
+BASH_REF="${BASH_REF:-bash}"
4445
 
4546
 # Check if fortsh exists
4647
 if [ ! -x "$FORTSH_BIN" ]; then
@@ -99,7 +100,7 @@ compare_posix_output() {
99100
     fortsh_file="/tmp/posix_gaps_$$_fortsh"
100101
 
101102
     # Run in POSIX shell (sh)
102
-    bash -c "$command" 2>&1 | normalize_output > "$posix_file" || true
103
+    "$BASH_REF" -c "$command" 2>&1 | normalize_output > "$posix_file" || true
103104
 
104105
     # Run in fortsh
105106
     "$FORTSH_BIN" -c "$command" 2>&1 | normalize_output > "$fortsh_file" || true
@@ -128,7 +129,7 @@ compare_posix_error() {
128129
     fortsh_file="/tmp/posix_gaps_$$_fortsh"
129130
 
130131
     # Run in POSIX shell (sh)
131
-    bash -c "$command" > "$posix_file" 2>&1 || true
132
+    "$BASH_REF" -c "$command" > "$posix_file" 2>&1 || true
132133
 
133134
     # Run in fortsh
134135
     "$FORTSH_BIN" -c "$command" > "$fortsh_file" 2>&1 || true
@@ -151,7 +152,7 @@ compare_posix_exit_code() {
151152
     test_name="$1"
152153
     command="$2"
153154
 
154
-    bash -c "$command" > /dev/null 2>&1
155
+    "$BASH_REF" -c "$command" > /dev/null 2>&1
155156
     posix_exit=$?
156157
 
157158
     "$FORTSH_BIN" -c "$command" > /dev/null 2>&1
tests/posix_compliance_options.shmodified
@@ -25,6 +25,7 @@ FAILED_TESTS_LIST=""
2525
 # Get script directory (POSIX way)
2626
 SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
2727
 FORTSH_BIN="${FORTSH_BIN:-$SCRIPT_DIR/../bin/fortsh}"
28
+BASH_REF="${BASH_REF:-bash}"
2829
 
2930
 # Check if fortsh exists
3031
 if [ ! -x "$FORTSH_BIN" ]; then
@@ -196,7 +197,7 @@ section "386. SET -v (VERBOSE)"
196197
 # Test that -v option is accepted and runs without error
197198
 "$FORTSH_BIN" -c 'set -v; echo hello' >/dev/null 2>&1
198199
 fortsh_exit=$?
199
-bash -c 'set -v; echo hello' >/dev/null 2>&1
200
+"$BASH_REF" -c 'set -v; echo hello' >/dev/null 2>&1
200201
 bash_exit=$?
201202
 if [ "$fortsh_exit" -eq "$bash_exit" ]; then
202203
     pass "set -v runs without error"
tests/posix_compliance_test.shmodified
@@ -28,6 +28,7 @@ FAILED_TESTS_LIST=""
2828
 # Get script directory (POSIX way)
2929
 SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
3030
 FORTSH_BIN="${FORTSH_BIN:-$SCRIPT_DIR/../bin/fortsh}"
31
+BASH_REF="${BASH_REF:-bash}"
3132
 
3233
 # Check if fortsh exists
3334
 if [ ! -x "$FORTSH_BIN" ]; then
@@ -81,7 +82,7 @@ compare_posix_output() {
8182
     fortsh_file="/tmp/posix_comp_$$_fortsh"
8283
 
8384
     # Run in POSIX shell (sh)
84
-    bash -c "$command" > "$posix_file" 2>&1 || true
85
+    "$BASH_REF" -c "$command" > "$posix_file" 2>&1 || true
8586
 
8687
     # Run in fortsh
8788
     "$FORTSH_BIN" -c "$command" > "$fortsh_file" 2>&1 || true
@@ -101,7 +102,7 @@ compare_posix_exit_code() {
101102
     test_name="$1"
102103
     command="$2"
103104
 
104
-    bash -c "$command" > /dev/null 2>&1
105
+    "$BASH_REF" -c "$command" > /dev/null 2>&1
105106
     posix_exit=$?
106107
 
107108
     "$FORTSH_BIN" -c "$command" > /dev/null 2>&1
tests/posix_compliance_untested.shmodified
@@ -24,6 +24,7 @@ FAILED_TESTS_LIST=""
2424
 # Get script directory (POSIX way)
2525
 SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
2626
 FORTSH_BIN="${FORTSH_BIN:-$SCRIPT_DIR/../bin/fortsh}"
27
+BASH_REF="${BASH_REF:-bash}"
2728
 
2829
 # Check if fortsh exists
2930
 if [ ! -x "$FORTSH_BIN" ]; then
@@ -74,7 +75,7 @@ compare_posix_output() {
7475
     test_cmd="$2"
7576
 
7677
     # Run with POSIX sh
77
-    posix_output=$(FORTSH_RC_FILE=/dev/null bash -c "$test_cmd" 2>&1)
78
+    posix_output=$(FORTSH_RC_FILE=/dev/null "$BASH_REF" -c "$test_cmd" 2>&1)
7879
     posix_exit=$?
7980
 
8081
     # Run with fortsh
@@ -100,7 +101,7 @@ compare_posix_error() {
100101
     test_name="$1"
101102
     test_cmd="$2"
102103
 
103
-    posix_output=$(FORTSH_RC_FILE=/dev/null bash -c "$test_cmd" 2>&1)
104
+    posix_output=$(FORTSH_RC_FILE=/dev/null "$BASH_REF" -c "$test_cmd" 2>&1)
104105
     posix_exit=$?
105106
 
106107
     fortsh_output=$(FORTSH_RC_FILE=/dev/null "$FORTSH_BIN" -c "$test_cmd" 2>&1)
tests/posix_gaps_arithmetic.shmodified
@@ -25,6 +25,7 @@ FAILED_TESTS_LIST=""
2525
 # Get script directory (POSIX way)
2626
 SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
2727
 FORTSH_BIN="${FORTSH_BIN:-$SCRIPT_DIR/../bin/fortsh}"
28
+BASH_REF="${BASH_REF:-bash}"
2829
 
2930
 # Check if fortsh exists
3031
 if [ ! -x "$FORTSH_BIN" ]; then
@@ -59,7 +60,7 @@ normalize_output() { sed -e 's/^bash: /sh: /' -e 's/line [0-9]*: //'; }
5960
 
6061
 compare_posix_output() {
6162
     test_name="$1"; command="$2"
62
-    posix_out=$(bash -c "$command" 2>&1 | normalize_output)
63
+    posix_out=$("$BASH_REF" -c "$command" 2>&1 | normalize_output)
6364
     fortsh_out=$("$FORTSH_BIN" -c "$command" 2>&1 | normalize_output)
6465
     if [ "$posix_out" = "$fortsh_out" ]; then pass "$test_name"
6566
     else fail "$test_name" "$posix_out" "$fortsh_out"; fi
@@ -67,7 +68,7 @@ compare_posix_output() {
6768
 
6869
 compare_posix_exit_code() {
6970
     test_name="$1"; command="$2"
70
-    bash -c "$command" >/dev/null 2>&1; posix_code=$?
71
+    "$BASH_REF" -c "$command" >/dev/null 2>&1; posix_code=$?
7172
     "$FORTSH_BIN" -c "$command" >/dev/null 2>&1; fortsh_code=$?
7273
     if [ "$posix_code" = "$fortsh_code" ]; then pass "$test_name"
7374
     else fail "$test_name" "exit $posix_code" "exit $fortsh_code"; fi
tests/posix_gaps_builtins.shmodified
@@ -25,6 +25,7 @@ FAILED_TESTS_LIST=""
2525
 # Get script directory (POSIX way)
2626
 SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
2727
 FORTSH_BIN="${FORTSH_BIN:-$SCRIPT_DIR/../bin/fortsh}"
28
+BASH_REF="${BASH_REF:-bash}"
2829
 
2930
 # Check if fortsh exists
3031
 if [ ! -x "$FORTSH_BIN" ]; then
@@ -59,7 +60,7 @@ normalize_output() { sed -e 's/^bash: /sh: /' -e 's/line [0-9]*: //'; }
5960
 
6061
 compare_posix_output() {
6162
     test_name="$1"; command="$2"
62
-    posix_out=$(bash -c "$command" 2>&1 | normalize_output)
63
+    posix_out=$("$BASH_REF" -c "$command" 2>&1 | normalize_output)
6364
     fortsh_out=$("$FORTSH_BIN" -c "$command" 2>&1 | normalize_output)
6465
     if [ "$posix_out" = "$fortsh_out" ]; then pass "$test_name"
6566
     else fail "$test_name" "$posix_out" "$fortsh_out"; fi
@@ -67,7 +68,7 @@ compare_posix_output() {
6768
 
6869
 compare_posix_exit_code() {
6970
     test_name="$1"; command="$2"
70
-    bash -c "$command" >/dev/null 2>&1; posix_code=$?
71
+    "$BASH_REF" -c "$command" >/dev/null 2>&1; posix_code=$?
7172
     "$FORTSH_BIN" -c "$command" >/dev/null 2>&1; fortsh_code=$?
7273
     if [ "$posix_code" = "$fortsh_code" ]; then pass "$test_name"
7374
     else fail "$test_name" "exit $posix_code" "exit $fortsh_code"; fi
@@ -75,7 +76,7 @@ compare_posix_exit_code() {
7576
 
7677
 compare_posix_error() {
7778
     test_name="$1"; command="$2"
78
-    posix_out=$(bash -c "$command" 2>&1 | normalize_output)
79
+    posix_out=$("$BASH_REF" -c "$command" 2>&1 | normalize_output)
7980
     fortsh_out=$("$FORTSH_BIN" -c "$command" 2>&1 | normalize_output)
8081
     if [ "$posix_out" = "$fortsh_out" ]; then pass "$test_name"
8182
     else fail "$test_name" "$posix_out" "$fortsh_out"; fi
tests/posix_gaps_charclass.shmodified
@@ -25,6 +25,7 @@ FAILED_TESTS_LIST=""
2525
 # Get script directory (POSIX way)
2626
 SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
2727
 FORTSH_BIN="${FORTSH_BIN:-$SCRIPT_DIR/../bin/fortsh}"
28
+BASH_REF="${BASH_REF:-bash}"
2829
 
2930
 # Check if fortsh exists
3031
 if [ ! -x "$FORTSH_BIN" ]; then
@@ -59,7 +60,7 @@ normalize_output() { sed -e 's/^bash: /sh: /' -e 's/line [0-9]*: //'; }
5960
 
6061
 compare_posix_output() {
6162
     test_name="$1"; command="$2"
62
-    posix_out=$(bash -c "$command" 2>&1 | normalize_output)
63
+    posix_out=$("$BASH_REF" -c "$command" 2>&1 | normalize_output)
6364
     fortsh_out=$("$FORTSH_BIN" -c "$command" 2>&1 | normalize_output)
6465
     if [ "$posix_out" = "$fortsh_out" ]; then pass "$test_name"
6566
     else fail "$test_name" "$posix_out" "$fortsh_out"; fi
tests/posix_gaps_control.shmodified
@@ -25,6 +25,7 @@ FAILED_TESTS_LIST=""
2525
 # Get script directory (POSIX way)
2626
 SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
2727
 FORTSH_BIN="${FORTSH_BIN:-$SCRIPT_DIR/../bin/fortsh}"
28
+BASH_REF="${BASH_REF:-bash}"
2829
 
2930
 # Check if fortsh exists
3031
 if [ ! -x "$FORTSH_BIN" ]; then
@@ -59,7 +60,7 @@ normalize_output() { sed -e 's/^bash: /sh: /' -e 's/line [0-9]*: //'; }
5960
 
6061
 compare_posix_output() {
6162
     test_name="$1"; command="$2"
62
-    posix_out=$(bash -c "$command" 2>&1 | normalize_output)
63
+    posix_out=$("$BASH_REF" -c "$command" 2>&1 | normalize_output)
6364
     fortsh_out=$("$FORTSH_BIN" -c "$command" 2>&1 | normalize_output)
6465
     if [ "$posix_out" = "$fortsh_out" ]; then pass "$test_name"
6566
     else fail "$test_name" "$posix_out" "$fortsh_out"; fi
@@ -97,7 +98,7 @@ compare_posix_output "for with break" 'for i in 1 2 3; do echo $i; break; done'
9798
 compare_posix_output "for with continue" 'for i in 1 2 3; do if [ $i = 2 ]; then continue; fi; echo $i; done'
9899
 # Inline test with debug output for CI diagnosis
99100
 _glob_cmd="touch /tmp/posix_gaps_for1_$$.txt /tmp/posix_gaps_for2_$$.txt /tmp/posix_gaps_for3_$$.txt 2>/dev/null; for f in /tmp/posix_gaps_for*_$$.txt; do test -f \$f && echo yes; done | head -1; rm -f /tmp/posix_gaps_for*_$$.txt"
100
-_glob_posix=$(bash -c "$_glob_cmd" 2>&1)
101
+_glob_posix=$("$BASH_REF" -c "$_glob_cmd" 2>&1)
101102
 _glob_fortsh=$("$FORTSH_BIN" -c "$_glob_cmd" 2>&1)
102103
 _glob_debug="[DEBUG glob] posix_hex=[$(printf '%s' "$_glob_posix" | od -A n -t x1 | tr -d '\n')] fortsh_hex=[$(printf '%s' "$_glob_fortsh" | od -A n -t x1 | tr -d '\n')] posix_raw=[$_glob_posix] fortsh_raw=[$_glob_fortsh]"
103104
 _glob_posix_n=$(printf '%s' "$_glob_posix" | normalize_output)
tests/posix_gaps_heredoc.shmodified
@@ -25,6 +25,7 @@ FAILED_TESTS_LIST=""
2525
 # Get script directory (POSIX way)
2626
 SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
2727
 FORTSH_BIN="${FORTSH_BIN:-$SCRIPT_DIR/../bin/fortsh}"
28
+BASH_REF="${BASH_REF:-bash}"
2829
 
2930
 # Check if fortsh exists
3031
 if [ ! -x "$FORTSH_BIN" ]; then
@@ -59,7 +60,7 @@ normalize_output() { sed -e 's/^bash: /sh: /' -e 's/line [0-9]*: //'; }
5960
 
6061
 compare_posix_output() {
6162
     test_name="$1"; command="$2"
62
-    posix_out=$(bash -c "$command" 2>&1 | normalize_output)
63
+    posix_out=$("$BASH_REF" -c "$command" 2>&1 | normalize_output)
6364
     fortsh_out=$("$FORTSH_BIN" -c "$command" 2>&1 | normalize_output)
6465
     if [ "$posix_out" = "$fortsh_out" ]; then pass "$test_name"
6566
     else fail "$test_name" "$posix_out" "$fortsh_out"; fi
@@ -67,7 +68,7 @@ compare_posix_output() {
6768
 
6869
 compare_posix_exit_code() {
6970
     test_name="$1"; command="$2"
70
-    bash -c "$command" >/dev/null 2>&1; posix_code=$?
71
+    "$BASH_REF" -c "$command" >/dev/null 2>&1; posix_code=$?
7172
     "$FORTSH_BIN" -c "$command" >/dev/null 2>&1; fortsh_code=$?
7273
     if [ "$posix_code" = "$fortsh_code" ]; then pass "$test_name"
7374
     else fail "$test_name" "exit $posix_code" "exit $fortsh_code"; fi
tests/posix_gaps_quoting.shmodified
@@ -25,6 +25,7 @@ FAILED_TESTS_LIST=""
2525
 # Get script directory (POSIX way)
2626
 SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
2727
 FORTSH_BIN="${FORTSH_BIN:-$SCRIPT_DIR/../bin/fortsh}"
28
+BASH_REF="${BASH_REF:-bash}"
2829
 
2930
 # Check if fortsh exists
3031
 if [ ! -x "$FORTSH_BIN" ]; then
@@ -59,7 +60,7 @@ normalize_output() { sed -e 's/^bash: /sh: /' -e 's/line [0-9]*: //'; }
5960
 
6061
 compare_posix_output() {
6162
     test_name="$1"; command="$2"
62
-    posix_out=$(bash -c "$command" 2>&1 | normalize_output)
63
+    posix_out=$("$BASH_REF" -c "$command" 2>&1 | normalize_output)
6364
     fortsh_out=$("$FORTSH_BIN" -c "$command" 2>&1 | normalize_output)
6465
     if [ "$posix_out" = "$fortsh_out" ]; then pass "$test_name"
6566
     else fail "$test_name" "$posix_out" "$fortsh_out"; fi
tests/posix_gaps_redirect.shmodified
@@ -25,6 +25,7 @@ FAILED_TESTS_LIST=""
2525
 # Get script directory (POSIX way)
2626
 SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
2727
 FORTSH_BIN="${FORTSH_BIN:-$SCRIPT_DIR/../bin/fortsh}"
28
+BASH_REF="${BASH_REF:-bash}"
2829
 
2930
 # Check if fortsh exists
3031
 if [ ! -x "$FORTSH_BIN" ]; then
@@ -59,7 +60,7 @@ normalize_output() { sed -e 's/^bash: /sh: /' -e 's/line [0-9]*: //'; }
5960
 
6061
 compare_posix_output() {
6162
     test_name="$1"; command="$2"
62
-    posix_out=$(bash -c "$command" 2>&1 | normalize_output)
63
+    posix_out=$("$BASH_REF" -c "$command" 2>&1 | normalize_output)
6364
     fortsh_out=$("$FORTSH_BIN" -c "$command" 2>&1 | normalize_output)
6465
     if [ "$posix_out" = "$fortsh_out" ]; then pass "$test_name"
6566
     else fail "$test_name" "$posix_out" "$fortsh_out"; fi
@@ -67,7 +68,7 @@ compare_posix_output() {
6768
 
6869
 compare_posix_exit_code() {
6970
     test_name="$1"; command="$2"
70
-    bash -c "$command" >/dev/null 2>&1; posix_code=$?
71
+    "$BASH_REF" -c "$command" >/dev/null 2>&1; posix_code=$?
7172
     "$FORTSH_BIN" -c "$command" >/dev/null 2>&1; fortsh_code=$?
7273
     if [ "$posix_code" = "$fortsh_code" ]; then pass "$test_name"
7374
     else fail "$test_name" "exit $posix_code" "exit $fortsh_code"; fi
tests/posix_gaps_special.shmodified
@@ -26,6 +26,7 @@ DEBUG_INFO=""
2626
 # Get script directory (POSIX way)
2727
 SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
2828
 FORTSH_BIN="${FORTSH_BIN:-$SCRIPT_DIR/../bin/fortsh}"
29
+BASH_REF="${BASH_REF:-bash}"
2930
 
3031
 # Check if fortsh exists
3132
 if [ ! -x "$FORTSH_BIN" ]; then
@@ -60,7 +61,7 @@ normalize_output() { sed -e 's/^bash: /sh: /' -e 's/line [0-9]*: //'; }
6061
 
6162
 compare_posix_output() {
6263
     test_name="$1"; command="$2"
63
-    posix_out=$(bash -c "$command" 2>&1 | normalize_output)
64
+    posix_out=$("$BASH_REF" -c "$command" 2>&1 | normalize_output)
6465
     fortsh_out=$("$FORTSH_BIN" -c "$command" 2>&1 | normalize_output)
6566
     if [ "$posix_out" = "$fortsh_out" ]; then pass "$test_name"
6667
     else