zsh-workers
 help / color / mirror / code / Atom feed
From: gak@klanderman.net (Greg Klanderman)
To: zsh-workers@sunsite.dk (Zsh list)
Subject: NOSHWORDSPLIT problem??
Date: Sun, 23 Feb 2003 18:08:10 -0500	[thread overview]
Message-ID: <15961.21594.705429.113987@gargle.gargle.HOWL> (raw)


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


                 reply	other threads:[~2003-02-23 23:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15961.21594.705429.113987@gargle.gargle.HOWL \
    --to=gak@klanderman.net \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).