Skip to content

Commit fae2be9

Browse files
author
Andy C
committed
[word_eval refactor] Add comments and extract variable
1 parent cdf3051 commit fae2be9

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

core/runtime.asdl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@ module runtime
4040
List[str] argv, List[CompoundWord] arg_locs,
4141
List[AssignArg] pairs)
4242

43-
# - Single or double quoted parts get neither split or globbed.
44-
# - Bare words like echo or *.py are globbed, but NOT split with IFS.
45-
# - Unquoted Substitutions are split and globbed.
43+
# A Piece is a part of a word that's been evaluated
44+
# Bare word | echo *.py | quoted=False do_split=False
45+
# Unquoted subst | $x ${x} | quoted=False do_split=True
46+
# Quoted string | 'sq' "$x" | quoted=True do_split=False
47+
# The 'quoted' flag is used to determine whether globbing will occur, as well
48+
# as empty elision like x=''; $x$x versus "$x"$x
4649
Piece = (str s, bool quoted, bool do_split)
4750

4851
# A parse-time word_part from syntax.asdl is evaluated to a runtime

osh/word_eval.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1798,12 +1798,13 @@ def _TranslateExtGlob(self, part_vals, w, glob_parts, fnmatch_parts):
17981798
We need both glob and fnmatch patterns. _EvalExtGlob does the
17991799
flattening.
18001800
"""
1801+
will_glob = not self.exec_opts.noglob()
18011802
for i, part_val in enumerate(part_vals):
18021803
UP_part_val = part_val
18031804
with tagswitch(part_val) as case:
18041805
if case(part_value_e.String):
18051806
part_val = cast(Piece, UP_part_val)
1806-
if part_val.quoted and not self.exec_opts.noglob():
1807+
if will_glob and part_val.quoted:
18071808
s = glob_.GlobEscape(part_val.s)
18081809
else:
18091810
# e.g. the @( and | in @(foo|bar) aren't quoted

0 commit comments

Comments
 (0)