Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
treatment of empty strings - why is this not a bug?
- X-seq: zsh-workers 26299
- From: Greg Klanderman <gak@xxxxxxxxxxxxxx>
- To: Zsh list <zsh-workers@xxxxxxxxxx>
- Subject: treatment of empty strings - why is this not a bug?
- Date: Tue, 13 Jan 2009 02:32:34 -0500
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- Reply-to: gak@xxxxxxxxxxxxxx
It's so nice that zsh doesn't do splitting on unquoted parameter
expansions:
[~] greg@lwm| zsh -f
lwm% function count () { echo $# }
lwm% a=( "a b" "c d" )
lwm% echo $#a[@]
2
lwm% count $a[@]
2
lwm% count "$a[@]"
2
however, it does silently drop empty strings:
lwm% a=( "" "" "" )
lwm% echo $#a[@]
3
lwm% count $a[@]
0
lwm% count "$a[@]"
3
which means you still have to use all those quotes anyway.
I just don't understand why there should be any distinction
between the splitting and dropping of empty strings.
And even using quotes, zsh's treatment of empty strings here
seems very inconsistent:
lwm% x=::: && for v in "${(s-:-)x}" ; do echo "v= =>$v<=" ; done
v= =><=
v= =><=
lwm% x=:a:b: && for v in "${(s-:-)x}" ; do echo "v= =>$v<=" ; done
v= =><=
v= =>a<=
v= =>b<=
v= =><=
thanks,
Greg
Messages sorted by:
Reverse Date,
Date,
Thread,
Author