zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: zsh-workers@sunsite.auc.dk
Subject: Re: BUG: zsh-3.1.5-pws-14: parameter expansion not working properly
Date: Wed, 14 Apr 1999 10:27:51 -0700	[thread overview]
Message-ID: <990414102751.ZM3847@candle.brasslantern.com> (raw)
In-Reply-To: <199904120717.JAA26054@beta.informatik.hu-berlin.de>

On Apr 12,  9:17am, Sven Wischnowsky wrote:
} Subject: Re: BUG: zsh-3.1.5-pws-14: parameter expansion not working proper
}
} The rule of thumb is now that one should use the `(@)' flag whenever
} the thing is in double quotes and one wants to work on arrays.

When I first saw the patch that introduced that change, I thought that
introducing the extra consistency sounded like a good thing.

	bar=(xa)
	print -l "${${(@)bar}[1]}" "${(@)${bar}[1]}"

Zsh 3.0.5 prints

	x
	x

But 3.1.5-pws-14 prints

	x
	xa

which is nice, because you can tell a singleton array from a scalar.

Now that I've seen/used it in practice a few times, I'm not so sure any
more.  The more radical change, and one which bothers me a lot, is the
effect when the array has more than one element:

	foo=(xa yb zc)
	print -l "${${(@)foo}[1]}" "${(@)${foo}[1]}"

Zsh 3.0.5 prints

	xa
	x

But 3.1.5-pws-14 prints

	x
	xa

That's completely reversed the semantics, and thus is a serious problem.

Another difficulty is that (@) has to be repeated at *every* level of a
nested expansion, from the innermost ${...} at which an array is desired
all the way to the outermost braces.

	"${${${${(@)foo}}}}"		== "$foo[@]"

To get the equivalent effect now, having to write

	"${(@)${(@)${(@)${(@)foo}}}}"	== "$foo[@]"

is error-prone and just plain annoying.  There must be a better way.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


  reply	other threads:[~1999-04-14 17:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-04-12  7:17 Sven Wischnowsky
1999-04-14 17:27 ` Bart Schaefer [this message]
  -- strict thread matches above, loose matches on Subject: below --
1999-05-10  9:13 Sven Wischnowsky
1999-04-16  7:36 Sven Wischnowsky
1999-04-16  7:48 ` Andrej Borsenkow
1999-04-16  9:04   ` Bart Schaefer
1999-04-16  9:26     ` Andrej Borsenkow
1999-04-18 23:39 ` Bart Schaefer
1999-05-07 11:51 ` Peter Stephenson
1999-05-07 13:36   ` Sven Wischnowsky
1999-05-09 17:49     ` Bart Schaefer
1999-04-15 12:08 Sven Wischnowsky
1999-04-15 20:10 ` Bart Schaefer
1999-04-15  6:49 Sven Wischnowsky
1999-04-15 11:03 ` Bart Schaefer
1999-04-10 11:28 Geoff Wing

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=990414102751.ZM3847@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).