| Q |
A |
| OS |
Linux (container) |
| Shell & version |
bash 3.00.22 and 3.2.57 |
| bashunit version |
0.50.1 |
Summary
test_src_has_no_append_assignment uses one pattern for two constructs that fail on different Bash versions. The array form is a parse error on Bash 3.0 and parses fine on 3.2, so it belongs in a stricter class than the string form.
Current behavior
tests/unit/project/bash_compatibility_test.sh:61-72 matches both x+=y and arr+=(x) with a single regex, and treats them as the same rule.
Measured on a real Bash 3.00.22 and on 3.2.57, with the construct placed inside if false; then ... fi and inside an uncalled function:
| Construct |
3.0 bash -n |
3.0 in dead code |
3.2 bash -n |
3.2 in dead code |
x+=y |
passes |
inert |
passes |
works live |
arr+=(x) |
fails |
fails |
passes |
works live |
So arr+=(x) kills the file on Bash 3.0 even where it is never reached, and a green macOS run says nothing about it. x+=y is inert in dead code on both.
Expected behavior
Split the rule in two, so the two constructs can carry different minimum versions. x+=y is a Bash 3.1 feature that is safe inside a branch 3.0 never takes. arr+=(x) can never be made safe on 3.0 by any guard, because the failure happens at parse time.
This matters beyond tidiness: the split is what lets the compat test tell "needs a version guard" from "can never appear at all". Found while checking which constructs could sit behind a version gate.
Summary
test_src_has_no_append_assignmentuses one pattern for two constructs that fail on different Bash versions. The array form is a parse error on Bash 3.0 and parses fine on 3.2, so it belongs in a stricter class than the string form.Current behavior
tests/unit/project/bash_compatibility_test.sh:61-72matches bothx+=yandarr+=(x)with a single regex, and treats them as the same rule.Measured on a real Bash 3.00.22 and on 3.2.57, with the construct placed inside
if false; then ... fiand inside an uncalled function:bash -nbash -nx+=yarr+=(x)So
arr+=(x)kills the file on Bash 3.0 even where it is never reached, and a green macOS run says nothing about it.x+=yis inert in dead code on both.Expected behavior
Split the rule in two, so the two constructs can carry different minimum versions.
x+=yis a Bash 3.1 feature that is safe inside a branch 3.0 never takes.arr+=(x)can never be made safe on 3.0 by any guard, because the failure happens at parse time.This matters beyond tidiness: the split is what lets the compat test tell "needs a version guard" from "can never appear at all". Found while checking which constructs could sit behind a version gate.