-
Notifications
You must be signed in to change notification settings - Fork 596
Description
What happened?
hi again,
[[ $a == (e|b) ]]
this breaks the rest of the file, apparently because it thinks the e|
is an unterminated e
glob qualifier. there are a few issues with this:
-
glob qualifiers must be preceded by a pattern, so a stand-alone
(...)
shouldn't be interpreted as one -
bare glob qualifiers -- the
(...)
form rather than the(#q...)
one -- can't contain|
, so even if it was preceded by a pattern it shouldn't be interpreted as one -
bare glob qualifiers (even legal ones) can't appear inside a
[[
condition -
extended glob qualifiers
(#q...)
can appear inside a[[
condition, but not on the right-hand side of a pattern-matching expression likea == b
ora != b
. i think they can appear anywhere else in one
(this is generally covered under Glob Qualifiers, but lmk if i can improve it, short of a formal grammar lol)
so
echo (e::) # not globqual (no preceding pattern)
echo (#qe::) # not globqual (no preceding pattern)
echo x(e||) # not globqual (bare globqual may not contain '|')
echo x(e::) # is globqual
echo x(#qe::) # is globqual
echo x(#qe||) # is globqual
[[ $a == x(.) ]] # not globqual (bare globqual not valid in [[ ... ]])
[[ x(.) == $a ]] # not globqual (bare globqual not valid in [[ ... ]])
[[ $a == x(#q.) ]] # not globqual (globqual not valid on rhs of [[ a == b ]])
[[ x(#q.) == $a ]] # is globqual
thanks again for your work on this