From: "Bart Schaefer" <schaefer@brasslantern.com>
To: zsh-workers@sunsite.auc.dk
Subject: Re: PATCH: zsh-3.1.5-pws-7: "$a[@]" with $a unset
Date: Fri, 12 Feb 1999 07:43:45 -0800 [thread overview]
Message-ID: <990212074345.ZM8144@candle.brasslantern.com> (raw)
In-Reply-To: <9902120928.AA34074@ibmth.df.unipi.it>
On Feb 12, 10:28am, Peter Stephenson wrote:
} Subject: PATCH: zsh-3.1.5-pws-7: "$a[@]" with $a unset
}
} Sven Wischnowsky wrote:
} > % foo() { echo $# }
} > % unset a
} > % foo $a[@]
} > 0 # fine
} > % foo "$a[@]"
} > 1 # oops
That's not an "oops". That's the way it's supposed to work. Try the
equivalent code in bash.
[schaefer@zagzig zsh-3.1.5-work]$ unset f
[schaefer@zagzig zsh-3.1.5-work]$ foo() { echo $#; echo "$@"; }
[schaefer@zagzig zsh-3.1.5-work]$ foo "$f[@]"
1
[@]
c[1] ksh
$ unset f
$ foo() { echo $#; echo "$@"; }
$ foo "$f[@]"
1
[@]
(I had to ssh to my old grad school account to get that ksh example.)
zagzig[32] ARGV0=ksh zsh
zagzig% unset f
zagzig% foo() { echo $#; echo "$@"; }
zagzig% foo "$f[@]"
1
[@]
} Note that putting `a=()' before would have been a workaround.
That's The Right Thing To Do, not a workaround.
} Quoted variables only expand to nothing if the @ is present.
On a scalar -- which is what `a' is if you've never done `a=()' -- the
string $a[@] expands to all the characters in the value of $a; it's the
same as just "$a". The quoted-@ magic doesn't apply when slicing a
scalar.
I don't think we want this patch.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
next prev parent reply other threads:[~1999-02-12 15:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-02-12 8:53 Tar file and Re: Bad interaction between -iprefix and -string Sven Wischnowsky
1999-02-12 9:28 ` PATCH: zsh-3.1.5-pws-7: "$a[@]" with $a unset Peter Stephenson
1999-02-12 15:43 ` Bart Schaefer [this message]
1999-02-12 15:45 ` Peter Stephenson
1999-02-12 17:33 ` Bart Schaefer
1999-02-13 7:05 ` PATCH: " Bart Schaefer
1999-02-12 9:48 Sven Wischnowsky
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=990212074345.ZM8144@candle.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@sunsite.auc.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).