Skip to content

Commit ad2fd70

Browse files
committed
glob: Fix GLOBIGNORE test for bash 4.4, add note
Bash 4.4 was released last night, and apparently the `GLOBIGNORE` behavior changed in a fashion that broke the 'glob/main: recursively discover files' case. Specifically, a pattern with a leading `*` doesn't seem to match arbitrarily deep subdirectory prefixes anymore. Expanding the `--ignore` argument to be more specific fixes the test for bash 4.4 and still works for previous versions.
1 parent da71b3f commit ad2fd70

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

libexec/glob

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
# NOTE: If a <glob> produces errors, or generally doesn't do as you expect,
4040
# you may need to include it in quotes so it isn't expanded by the shell
4141
# _before_ executing the {{cmd}} command.
42+
#
43+
# NOTE FOR BASH 4.4: Something changed with GLOBIGNORE behavior such that
44+
# `GLOBIGNORE` patterns of the form `*ignore-me` no longer match arbitrarily
45+
# deep subdirectory prefixes. Consequently, you may need to use multiple
46+
# `--ignore` patterns to achieve the same effect.
4247

4348
_@go.glob_impl() {
4449
local pattern="$1"

tests/glob/main.bats

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,12 @@ teardown() {
201201
"quux/xyzzy"
202202
"quux/xyzzy/frotz")
203203

204-
run ./go glob --ignore '*ignore-me*' --trim "$TESTS_DIR" '.bats'
204+
# The `--ignore` pattern below was previously '*ignore-me*'. This worked on
205+
# bash 3.2, 4.2, and 4.3. However, something changed in bash 4.4 that caused
206+
# that pattern not to work at all anymore. The current pattern works for all
207+
# bash versions.
208+
run ./go glob --ignore 'ignore-me:*/ignore-me:foo/bar/baz/ignore-me*' \
209+
--trim "$TESTS_DIR" '.bats'
205210
local IFS=$'\n'
206211
assert_success "${expected[*]}"
207212
}

0 commit comments

Comments
 (0)