Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: foo=($bar) vs foo=("$bar[@]")
- X-seq: zsh-users 632
- From: Peter Stephenson <pws@xxxxxx>
- To: zsh-users@xxxxxxxxxxxxxxx (Zsh users list), Roderick Schertler <roderick@xxxxxxxx>
- Subject: Re: foo=($bar) vs foo=("$bar[@]")
- Date: Wed, 29 Jan 1997 09:14:24 +0100
- In-reply-to: "Roderick Schertler"'s message of "Wed, 29 Jan 1997 00:07:32 MET." <27155.854514452@xxxxxxxxxxxxxxxxx>
Roderick Schertler wrote:
> The NEWS file says
>
> foo=$bar no longer creates an array even if bar is an array. Use
> foo=( $bar ) or even better, foo=( "$bar[@]" ) instead.
>
> In what way is "$bar[@]" better than $bar?
I think the point is it works even if shwordsplit is set.
% setopt shwordsplit
% args() { echo $#; }
% bar=('one word' 'another word')
% args $bar
4 # i.e. 'one' 'word' 'another' 'word'
% args "$bar[@]"
2 # i.e. 'one word' 'another word'
It still doesn't quite make ksh users feel it home, it needs to be
"${bar[@]}" for that. In fact, with ksharrays (or `emulate ksh')
turned on you need it in zsh too, so perhaps the NEWS file ought to
have that if it's trying to be all-inclusive.
--
Peter Stephenson <pws@xxxxxx> Tel: +49 33762 77366
WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77413
Deutsches Elektronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author