Skip to content

Commit

Permalink
[glob] Fix crash with 'set -o noglob'
Browse files Browse the repository at this point in the history
Bug #698.

The nested 'else' case was messed up!  Gah.
  • Loading branch information
Andy Chu committed Apr 15, 2020
1 parent e342028 commit 35bd053
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
17 changes: 7 additions & 10 deletions osh/word_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -1580,16 +1580,13 @@ def _EvalWordFrame(self, frame, argv):
# Array of strings, some of which are BOTH IFS-escaped and GLOB escaped!
frags = [] # type: List[str]
for frag, quoted, do_split in frame:
if will_glob:
if quoted:
frag = glob_.GlobEscape(frag)
else:
# We're going to both split and glob, so backslash escape TWICE.

# If we have a literal \, then we turn it into \\\\.
# Splitting takes \\\\ -> \\
# Globbing takes \\ to \ if it doesn't match
frag = _BackslashEscape(frag)
if will_glob and quoted:
frag = glob_.GlobEscape(frag)
else:
# If we have a literal \, then we turn it into \\\\.
# Splitting takes \\\\ -> \\
# Globbing takes \\ to \ if it doesn't match
frag = _BackslashEscape(frag)

if do_split:
frag = _BackslashEscape(frag)
Expand Down
2 changes: 1 addition & 1 deletion test/spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ sh-func() {

glob() {
# Note: can't pass because it assumes 'bin' exists, etc.
sh-spec spec/glob.test.sh --no-cd-tmp --osh-failures-allowed 8 \
sh-spec spec/glob.test.sh --no-cd-tmp --osh-failures-allowed 7 \
${REF_SHELLS[@]} $BUSYBOX_ASH $OSH_LIST "$@"
}

Expand Down

0 comments on commit 35bd053

Please sign in to comment.