1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-06-12 07:28:04 +02:00

52465: use NULL_GLOB when expanding zmv input pattern to avoid NOMATCH exit

This commit is contained in:
Bart Schaefer 2024-01-05 20:38:58 -08:00
parent a528af5c57
commit d6e4ddd4d4
3 changed files with 16 additions and 5 deletions
ChangeLog
Doc/Zsh
Functions/Misc

View file

@ -1,3 +1,8 @@
2024-01-05 Bart Schaefer <schaefer@zsh.org>
* 52465: Doc/Zsh/contrib.yo, Functions/Misc/zmv: use NULL_GLOB
when expanding the input pattern to avoid NOMATCH exit
2023-12-06 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> 2023-12-06 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
* 52413: Completion/Unix/Command/_iconv: support Citrus version * 52413: Completion/Unix/Command/_iconv: support Citrus version

View file

@ -4668,10 +4668,10 @@ renames `tt(foo.lis)' to `tt(foo.txt)', `tt(my.old.stuff.lis)' to
The pattern is always treated as an tt(EXTENDED_GLOB) pattern. Any file The pattern is always treated as an tt(EXTENDED_GLOB) pattern. Any file
whose name is not changed by the substitution is simply ignored. Any whose name is not changed by the substitution is simply ignored. Any
error (a substitution resulted in an empty string, two substitutions gave error (no files matched the var(srcpat), substitution resulted in an empty
the same result, the destination was an existing regular file and tt(-f) string, two substitutions gave the same result, the destination was an
was not given) causes the entire function to abort without doing existing regular file and tt(-f) was not given) causes the entire function
anything. to abort without doing anything.
In addition to pattern replacement, the variable tt($f) can be referred In addition to pattern replacement, the variable tt($f) can be referred
to in the second (replacement) argument. This makes it possible to to in the second (replacement) argument. This makes it possible to

View file

@ -236,12 +236,18 @@ if [[ $pat = (#b)(*)\((\*\*##/)\)(*) ]]; then
else else
fpat=$pat fpat=$pat
fi fi
files=(${~fpat})
[[ -n $hasglobqual ]] && pat=$opat [[ -n $hasglobqual ]] && pat=$opat
errs=() errs=()
() {
# (#qN) breaks bareglobqual -Q option, so:
setopt localoptions nullglob
files=(${~fpat})
}
(( ${#files} )) || errs=( "no files matched \`$fpat'" )
for f in $files; do for f in $files; do
if [[ $pat = (#b)(*)\(\*\*##/\)(*) ]]; then if [[ $pat = (#b)(*)\(\*\*##/\)(*) ]]; then
# This looks like a recursive glob. This isn't good enough, # This looks like a recursive glob. This isn't good enough,