zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh-workers@zsh.org
Subject: Re: The ~ parameter expansion flag: bug or misunderstanding
Date: Tue, 09 Sep 2014 17:41:09 +0100	[thread overview]
Message-ID: <20140909174109.038d3b3e@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <CAKjp4B7Xbenzk9Ro6Kxz447csRmwwxJEhAronZJW+RZ5PuJr8w@mail.gmail.com>

On Tue, 09 Sep 2014 12:21:16 -0400
Clint Hepner <clint.hepner@gmail.com> wrote:
> Thanks. One thing I still can't quite wrap my mind around is a scenario
> where
> 
>     ${(j.|.)~array}
> 
> and
> 
>     ${~j.|.)array}
> 
> would behave differently.

It depends on the contents of array.  Here's the sort of scenario that
caused the ~ inside the parentheses to be added.

Supposing someone has helpfully created a file "a|b", and your array is
a list of files in the current directory,

array=(*)

so it contains an alement "a|b".  zsh with its default settings usually
handles that fine because it makes a point of not expanding the results
of variable substitutions as patterns for exactly this reason.

However, when you do ${(j.|.)~array} it looks like two alternatives, a
or b, because the "|" in the value of $array is expanded.

If you do ${(~j.|.)array}, on the other hand, the "a|b" is kept with the
| as an ordinary character, so it still works.

pws


  reply	other threads:[~2014-09-09 16:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-03 14:58 Clint Hepner
2014-09-03 15:14 ` Peter Stephenson
2014-09-04  3:18   ` Bart Schaefer
2014-09-04 19:10     ` Peter Stephenson
2014-09-03 15:44 ` Bart Schaefer
2014-09-09 16:21   ` Clint Hepner
2014-09-09 16:41     ` Peter Stephenson [this message]
2014-09-09 16:54       ` Clint Hepner

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=20140909174109.038d3b3e@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.com \
    --cc=zsh-workers@zsh.org \
    /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).