zsh-workers
 help / color / mirror / code / Atom feed
From: DervishD <raul@pleyades.net>
To: Wayne Davison <wayned@users.sourceforge.net>
Cc: Zsh <zsh-workers@sunsite.dk>
Subject: Re: Little doubt about an expansion flag
Date: Sat, 6 Sep 2003 23:20:43 +0200	[thread overview]
Message-ID: <20030906212043.GD175@DervishD> (raw)
In-Reply-To: <20030906203647.GE24100@binome.blorf.net>

    Hi Wayne :)

 * Wayne Davison <wayned@users.sourceforge.net> dixit:
> >     and I'm looking (deciphering is more appropriate) at the first
> > part, namely ${(f)"$(ps xh)"}. When doing this, the output of the ps
> > command is *joined*, deleting the \n characters!!!
> Nope, the \n characters are not deleted because of the double quotes.

    Not exactly in this case... The problem was the 'echo' command I
was using. With 'print -l', which outputs *elements* separated by
whitespace, I can see that the (f) modifier is splitting the output
of the ps command into the lines and not into the spaces, so we can
do the matching on complete lines.

    Now I understand it, thanks to print -l :)))

> Try this:
>     echo "$(ps xh)"
> You'll see that they are still there.

    But the (f) modifier strips then and do splitting on them, and
not in words... When using echo I was using double quotes. I mean,
when doing the command (ps or whatever), let's have 'foo bar\nfoo2
bar2\nlastline' as output. Well, then we have:

    $echo $(command)
    foo bar foo2 bar2 lastline

    $echo "$(command)"
    foo bar
    foo2 bar2
    lastline

    $echo "${(f)"$(command"}"
    foo bar foo2 bar2 lastline

    $print -l "${(f)"$(command"}"
    foo bar
    foo2 foo2
    lastline
    

    What I didn't understand was the last 'echo' command, before the
'print -l' one. That's because echo has no idea about elements and
the like, print has. Now I understand all this. I should get used to
employ 'print' instead of 'echo', definitely ;)))

> >     Finally, I would like to know how the shell manages to parse
> > this: "${(f)"$(ps xh)"}", because it seems that the shell can read my
> > mind and parses the quotes nested, and not like "${(f)" $(ps xh) "}".
> Yes, this happens inside ${...} -- quotes start over in their nesting.

    OK, gotcha, thanks a lot for explaining :)

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/


      reply	other threads:[~2003-09-06 21:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-06 19:43 DervishD
2003-09-06 20:36 ` Wayne Davison
2003-09-06 21:20   ` DervishD [this message]

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=20030906212043.GD175@DervishD \
    --to=raul@pleyades.net \
    --cc=wayned@users.sourceforge.net \
    --cc=zsh-workers@sunsite.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).