zsh-users
 help / color / mirror / code / Atom feed
From: "Jérémie Roquet" <arkanosis@gmail.com>
To: Sebastian Stark <seb-zsh@biskalar.de>
Cc: zsh-users@zsh.org
Subject: Re: double quoted expansion question
Date: Fri, 7 Sep 2012 14:47:08 +0200	[thread overview]
Message-ID: <CAFOazANjtNgy23x+1hPKsQ2hKDTQc2RwF2STU5baszFmX95XNw@mail.gmail.com> (raw)
In-Reply-To: <29236168-55B5-4555-9ACA-B1D21D345EA9@biskalar.de>

Hi,

2012/9/7 Sebastian Stark <seb-zsh@biskalar.de>:
> I am trying to make a unique list of tags that is given in a string with a certain format, e.  g.:
>
>   servers="
>   madeira linux,gpu,users
>   madeira2 linux,gpu,users
>   smtp linux,mail,smtp
>   isar linux,users
>   easygwa linux,web,external
>   "
>
> The format is: server name, space, tag, comma, tag, comma, tag ...
>
> What I want from the above list is this:
>
>   external gpu linux mail smtp users web
>
> and I get it with:
>
>   print  ${(s:,:uo)${(j:,:)${${(f)servers}//* /}}}
>
> However, if I do this:
>
>   print "${(s:,:uo)${(j:,:)${${(f)servers}//* /}}}"
>
> I get:
>
>   external linux web
>
> This also happens when I use the variable expansion expression in a here document, which, I suppose, is undergoing the same treatment as double quoted strings.
>
> What I would like to understand here is why the output changes the way it does when I add double quotes around my expression. I would expect the same output as without. If anybody could shed some light please, I guess it's just something obvious I cannot see.

I'm not 100 % sure, but I suppose the quotes prevents the shell from
splitting your string on $IFS, so you only have *one* string, and the
“//* /" expression suppresses everything before the last space,
leaving only the tags of the last line.

Best regards,

-- 
Jérémie


  reply	other threads:[~2012-09-07 12:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-07 12:31 Sebastian Stark
2012-09-07 12:47 ` Jérémie Roquet [this message]
2012-09-07 12:54   ` Jérémie Roquet
2012-09-07 14:36     ` Sebastian Stark
2012-09-07 14:41 ` Bart Schaefer
2012-09-07 15:43 ` Sebastian Stark
2012-09-08  5:38   ` Bart Schaefer

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=CAFOazANjtNgy23x+1hPKsQ2hKDTQc2RwF2STU5baszFmX95XNw@mail.gmail.com \
    --to=arkanosis@gmail.com \
    --cc=seb-zsh@biskalar.de \
    --cc=zsh-users@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).