zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ifh.de>
To: zsh-users@math.gatech.edu (Zsh users list),
	Roderick Schertler <roderick@gate.net>
Subject: Re: foo=($bar) vs foo=("$bar[@]")
Date: Wed, 29 Jan 1997 09:14:24 +0100	[thread overview]
Message-ID: <199701290814.JAA03482@hydra.ifh.de> (raw)
In-Reply-To: "Roderick Schertler"'s message of "Wed, 29 Jan 1997 00:07:32 MET." <27155.854514452@eeyore.ibcinc.com>

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@ifh.de>       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.


  reply	other threads:[~1997-01-29  9:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-01-29  5:07 Roderick Schertler
1997-01-29  8:14 ` Peter Stephenson [this message]
1997-01-29 15:17 ` Zefram
1997-01-29 15:45   ` Roderick Schertler

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=199701290814.JAA03482@hydra.ifh.de \
    --to=pws@ifh.de \
    --cc=roderick@gate.net \
    --cc=zsh-users@math.gatech.edu \
    /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).