1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-01 21:51:40 +02:00

53709: tests: add misc. glob-qualifier tests

This commit is contained in:
dana 2025-06-03 02:01:15 -05:00
parent a9bde1b8d1
commit bde2b183ff
2 changed files with 62 additions and 0 deletions

View file

@ -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

View file

@ -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