Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Inconsistent behavior with comparisons and recursive glob patterns
- X-seq: zsh-users 29862
- From: Alan Wagner-Krankel <awk@xxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Inconsistent behavior with comparisons and recursive glob patterns
- Date: Tue, 30 Apr 2024 03:14:46 -0500
- Archived-at: <https://zsh.org/users/29862>
- List-id: <zsh-users.zsh.org>
The results of these conditional expressions using recursive glob
operators were unexpectedly different:
> [[ f0 = **/f? ]] && print true || print false
false
> setopt extendedglob
> [[ f0 = (*/)#f? ]] && print true || print false
true
Since **/ is a shorthand version of (*/)#, it seems like they both
should have returned 'true'. The comparisons behave the same when
there is at least one directory in the path:
> [[ d1/f1 = **/f? ]] && print true || print false
true
> setopt extendedglob
> [[ d1/f1 = (*/)#f? ]] && print true || print false
true
I came across this because it affects the behavior of zmv, via a test
that filters filenames (line 254 in zsh5.9). An example:
> mkdir d1 d1/d2
> touch f0 d1/f1 d1/d2/f2
> print -rl -- **/f?
d1/d2/f2
d1/f1
f0
> autoload zmv
> zmv -n '**/f?' '$f.txt'
mv -- d1/d2/f2 d1/d2/f2.txt
mv -- d1/f1 d1/f1.txt
> zmv -n '(*/)#f?' '$f.txt'
mv -- d1/d2/f2 d1/d2/f2.txt
mv -- d1/f1 d1/f1.txt
mv -- f0 f0.txt
I think both zmv calls should have attempted to update the 'f0' file
in the base directory. Am I missing something?
Thanks,
Awk
Messages sorted by:
Reverse Date,
Date,
Thread,
Author