mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-02 10:01:11 +02:00
53709: tests: add misc. glob-qualifier tests
This commit is contained in:
parent
a9bde1b8d1
commit
bde2b183ff
2 changed files with 62 additions and 0 deletions
|
@ -1,5 +1,7 @@
|
||||||
2025-06-03 dana <dana@dana.is>
|
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
|
* 53709: Doc/Zsh/expn.yo, Doc/Zsh/options.yo: clarify
|
||||||
glob-qualifier syntax
|
glob-qualifier syntax
|
||||||
|
|
||||||
|
|
|
@ -541,6 +541,19 @@
|
||||||
>No file beginning with z
|
>No file beginning with z
|
||||||
>Normal string if nullglob not set
|
>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/dir*(Y1)
|
||||||
(){ print $#@ } glob.tmp/file*(NY1)
|
(){ print $#@ } glob.tmp/file*(NY1)
|
||||||
(){ [[ "$*" == */dir?\ */dir? ]] && print Returns matching filenames } glob.tmp/dir*(Y2)
|
(){ [[ "$*" == */dir?\ */dir? ]] && print Returns matching filenames } glob.tmp/dir*(Y2)
|
||||||
|
@ -841,6 +854,53 @@
|
||||||
[[ abc = (b*|a*)~^(*b) ]]
|
[[ abc = (b*|a*)~^(*b) ]]
|
||||||
1:Regression test for exclusion after branches: failure case 3
|
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.
|
# Careful: extendedglob off from this point.
|
||||||
|
|
||||||
unsetopt extendedglob
|
unsetopt extendedglob
|
||||||
|
|
Loading…
Reference in a new issue