Commit 0d8bd29
committed
new: Fix tests under 3.2.57(1)-release
Under Bash 3.2.57(1)-release, `./go test new` was failing with:
```
✗ new: tab complete --internal
(in test file tests/new.bats, line 76)
`touch "${internal_modules[@]}"' failed
touch: (/var/folders/dl/0j29q1wd0w715j4gnz5ry_pc0000gn/T/test rootdir/scripts/lib/foo): No such file or directory
✗ new: tab complete --public
(in test file tests/new.bats, line 94)
`touch "${public_modules[@]}"' failed
touch: (/var/folders/dl/0j29q1wd0w715j4gnz5ry_pc0000gn/T/test rootdir/lib/xyzzy): No such file or directory
✗ new: tab complete --test
(in test file tests/new.bats, line 112)
`touch "${test_files[@]}"' failed
touch: (/var/folders/dl/0j29q1wd0w715j4gnz5ry_pc0000gn/T/test rootdir/tests/frotz.bats): No such file or directory
✗ new: tab complete --type
(in test file tests/new.bats, line 130)
`touch "${text_files[@]}"' failed
touch: (/var/folders/dl/0j29q1wd0w715j4gnz5ry_pc0000gn/T/test rootdir/gue/wizard.txt): No such file or directory
```
At first I thought this was the "declare and initialize an array at the
same time" bug from commit b421c73 and
commit c6bf1cf, as the workaround was
the same: declare the array on one line, and initialize it on another.
After thinking it through, however, I realized this bug was different,
since the earlier bug had to do with exported arrays not getting
initialized, and these arrays were `local`. On top of that, it appeared
that the brace expansion was to blame, since `touch` appeared to see
only the final brace expansion value, and that value was wrapped in
parentheses.
To verify this, I added this line before one of the `touch` calls:
printf 'ARG: %s\n' "${internal_modules[@]}" >&2
which produced:
✗ new: tab complete --internal
(in test file tests/new.bats, line 77)
`touch "${internal_modules[@]}"' failed
ARG: (/var/folders/dl/0j29q1wd0w715j4gnz5ry_pc0000gn/T/test rootdir/scripts/lib/foo)
touch: (/var/folders/dl/0j29q1wd0w715j4gnz5ry_pc0000gn/T/test rootdir/scripts/lib/foo): No such file or directory
After reviewing https://tiswww.case.edu/php/chet/bash/CHANGES, this
appeared to be the most likely culprit:
This document details the changes between this version,
bash-4.1-alpha, and the previous version, bash-4.0-release.
bb. Fixed a bug that caused brace expansion to take place too soon in
some compound array assignments.
Using the methodology described in the log message for commit
99ab780, I downloaded the Bash 4.0 and
4.1 sources and patches, and confirmed that the bug manifested under
Bash 4.0.44 (the highest patchlevel for 4.0) and did not manifest under
Bash 4.1.
Also, for future reference, the official Bash git repository is at:
https://savannah.gnu.org/git/?group=bash
http://git.savannah.gnu.org/cgit/bash.git
However, neither the patches from
https://mirrors.ocf.berkeley.edu/gnu/bash/ nor the Git repository show a
specific change for the fix, and the diff between 4.0.44 and 4.1 is too
large and difficult to parse to easily identify the fix.1 parent bb21e63 commit 0d8bd29
1 file changed
+8
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
| 88 | + | |
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
| |||
102 | 103 | | |
103 | 104 | | |
104 | 105 | | |
105 | | - | |
| 106 | + | |
| 107 | + | |
106 | 108 | | |
107 | 109 | | |
108 | 110 | | |
| |||
120 | 122 | | |
121 | 123 | | |
122 | 124 | | |
123 | | - | |
| 125 | + | |
| 126 | + | |
124 | 127 | | |
125 | 128 | | |
126 | 129 | | |
| |||
138 | 141 | | |
139 | 142 | | |
140 | 143 | | |
141 | | - | |
| 144 | + | |
| 145 | + | |
142 | 146 | | |
143 | 147 | | |
144 | 148 | | |
| |||
0 commit comments