summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordana <dana@dana.is>2025-06-03 02:01:15 -0500
committerdana <dana@dana.is>2025-06-03 02:01:35 -0500
commitbde2b183ffc9fa89d1d8aed82f7f95c692e6751a (patch)
tree94f20ab34717cf8b0437acc002c936bb51c63dd0
parent53709: docs: clarify glob-qualifier syntax (diff)
downloadzsh-bde2b183ffc9fa89d1d8aed82f7f95c692e6751a.tar
zsh-bde2b183ffc9fa89d1d8aed82f7f95c692e6751a.tar.gz
zsh-bde2b183ffc9fa89d1d8aed82f7f95c692e6751a.tar.bz2
zsh-bde2b183ffc9fa89d1d8aed82f7f95c692e6751a.tar.lz
zsh-bde2b183ffc9fa89d1d8aed82f7f95c692e6751a.tar.xz
zsh-bde2b183ffc9fa89d1d8aed82f7f95c692e6751a.tar.zst
zsh-bde2b183ffc9fa89d1d8aed82f7f95c692e6751a.zip
53709: tests: add misc. glob-qualifier tests
-rw-r--r--ChangeLog2
-rw-r--r--Test/D02glob.ztst60
2 files changed, 62 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index e6d651144..323c036fc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2025-06-03 dana <dana@dana.is>
+ * 53709: Test/D02glob.ztst: add misc. glob-qualifier tests
+
* 53709: Doc/Zsh/expn.yo, Doc/Zsh/options.yo: clarify
glob-qualifier syntax
diff --git a/Test/D02glob.ztst b/Test/D02glob.ztst
index 4d88e5c27..24494d274 100644
--- a/Test/D02glob.ztst
+++ b/Test/D02glob.ztst
@@ -541,6 +541,19 @@
>No file beginning with z
>Normal string if nullglob not set
+ (
+ setopt extended_glob no_nomatch
+ cd glob.tmp
+ [[ a(#q.) == a ]] && print lhs 1
+ [[ a(#q/) == a ]] && print lhs 2
+ [[ z == *(#q.) ]] && print rhs 1 # (#q...) ignored
+ [[ z == *(#q/) ]] && print rhs 2 # (#q...) ignored
+ )
+0:(#q) glob expansion only on lhs of pattern-match conditions
+>lhs 1
+>rhs 1
+>rhs 2
+
(){ print $#@ } glob.tmp/dir*(Y1)
(){ print $#@ } glob.tmp/file*(NY1)
(){ [[ "$*" == */dir?\ */dir? ]] && print Returns matching filenames } glob.tmp/dir*(Y2)
@@ -841,6 +854,53 @@
[[ abc = (b*|a*)~^(*b) ]]
1:Regression test for exclusion after branches: failure case 3
+ (
+ setopt extended_glob
+ cd glob.tmp
+ qual=.
+ echo [a](.) [a]('.') [a](".") [a](\.) [a]($qual) [a]("$qual")
+ echo [a](#q.) [a](#q'.') [a](#q".") [a](#q\.) [a](#q$qual) [a](#q"$qual")
+ qual='(#q.)'; echo [a]$~qual
+ qual='(#'; echo [a]${~qual}q.${:-)}
+ qual='(#q'; echo [a]${~qual}.${:-)}
+ )
+0:general glob qualifier quoting and expansion
+>a a a a a a
+>a a a a a a
+>a
+>a
+>a
+
+ (
+ setopt extended_glob
+ cd glob.tmp
+ s='*' quals=(
+ '(#qe:"REPLY=*":)' '(#qe":REPLY=*:")' '(#qe:REPLY=\*:)'
+ '(#qe:"reply=( \* )":)' '(#qe":reply=( \* ):")' '(#qe:reply=( \\\* ):)'
+ '(#qe|"reply=( \* )"|)' '(#qe"|reply=( \* )|")' '(#qe|reply=( \\\* )|)'
+ '(#qe?"reply=( \* )"?)' '(#qe"?reply=( \* )?")' '(#qe?reply=( \\\* )?)'
+ '(#qe["reply=( \* )"])' '(#qe"[reply=( \* )]")' '(#qe[reply=( \\\* )])'
+ '(#qe("reply=( \* )"))' '(#qe"(reply=( \* ))")' '(#qe(reply=( \\\* )))'
+ '(#qe*"reply=( \* )"*)' '(#qe"*reply=( \* )*")' '(#qe*reply=( \\\* )*)'
+ '(#qe*"reply=( \$s )"*)' '(#qe"*reply=( \$s )*")' '(#qe*reply=( \$s )*)'
+ )
+ for 1 2 3 in $quals; do
+ print -r - \
+ ${ eval "echo [a]$1" 2>&1 } \
+ ${ eval "echo [a]$2" 2>&1 } \
+ ${ eval "echo [a]$3" 2>&1 }
+ done
+ )
+0:e glob qualifier delimiters, quoting, and expansion
+>* * *
+>* * *
+>* * *
+>* * *
+>* * *
+>* (eval):1: unknown file attribute: ) (eval):1: unknown file attribute: )
+>* (eval):1: unknown file attribute: *
+>* * *
+
# Careful: extendedglob off from this point.
unsetopt extendedglob