zsh-workers
 help / color / mirror / code / Atom feed
* NOSHWORDSPLIT problem??
@ 2003-02-23 23:08 Greg Klanderman
  0 siblings, 0 replies; only message in thread
From: Greg Klanderman @ 2003-02-23 23:08 UTC (permalink / raw)
  To: Zsh list


Hi,

I've been trying to wean myself from using double quotes around
everything since my understanding was that with SHWORDSPLIT unset this
was no longer needed.  However, there does seem to be a case when you
still get screwed, and I'm wondering if that is intentional or a bug
in zsh.  You still run into trouble if you have a variable containing
the empty string.

First some preliminaries:

phl% /bin/zsh-4.0.6 -f
phl% 
phl% echo $ZSH_VERSION
4.0.6
phl% unsetopt shwordsplit
phl% function count () { echo $# }
phl% 
phl% w="foo"
phl% x="bar baz"
phl% y=" space-on-either-end "
phl% z=""

When $z is not enclosed in double quotes, the empty string does not
make it into the array a:

phl% a=( $w $x $y $z )
phl% echo $#a
3
phl% count $a[@]                                
3
phl% for v in $a[@] ; do echo "v= \"$v\"" ; done
v= "foo"
v= "bar baz"
v= " space-on-either-end "

If $z is enclosed in double quotes, the empty string does make it into
the array a, but I further need to enclose expansions of the form
$a[@] in double quotes to have it not be elided:

phl% a=( $w $x $y "$z" )
phl% echo $#a                                   
4
phl% count $a[@]                                
3
phl% for v in $a[@] ; do echo "v= \"$v\"" ; done
v= "foo"
v= "bar baz"
v= " space-on-either-end "
phl% for v in "$a[@]" ; do echo "v= \"$v\"" ; done
v= "foo"
v= "bar baz"
v= " space-on-either-end "
v= ""

This seems pretty broken to me, because I still need to use all those
silly double quotes that NOSHWORDSPLIT is supposed to avoid.

thanks,
Greg


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-02-23 23:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-23 23:08 NOSHWORDSPLIT problem?? Greg Klanderman

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).