zsh-users
 help / color / mirror / code / Atom feed
From: Vincent Bernat <bernat@luffy.cx>
To: "Lawrence Velázquez" <larryv@zsh.org>
Cc: zsh-users@zsh.org
Subject: Re: (z) expansion flag do not always return an array
Date: Mon, 29 Nov 2021 18:43:36 +0100	[thread overview]
Message-ID: <m3fsreeu2f.fsf@luffy.cx> (raw)
In-Reply-To: <1be1289c-c3a1-4730-baab-5625af464cb1@www.fastmail.com> ("Lawrence =?utf-8?Q?Vel=C3=A1zquez=22's?= message of "Mon, 29 Nov 2021 11:50:38 -0500")

 ❦ 29 November 2021 11:50 -05, Lawrence Velázquez:

>> The (z) expansion flag is documented to return an array
>
> Is it?  The 5.8 man page does not mention "array" even once.
>
>     z   Split the result of the expansion into words using shell
>         parsing to find the words, i.e. taking into account any
>         quoting in the value.  Comments are not treated specially but
>         as ordinary strings, similar to interactive shells with the
>         INTERACTIVE_COMMENTS option unset (however, see the Z flag
>         below for related options)
>
>         Note that this is done very late, even later than the `(s)'
>         flag.  So to access single words in the result use nested
>         expansions as in `${${(z)foo}[2]}'.  Likewise, to remove the
>         quotes in the resulting words use `${(Q)${(z)foo}}'.

When I read "split", I read "into an array". I must miss something.
Also, it works when there is something to split, but not when there is
only one word.
-- 
Don't use conditional branches as a substitute for a logical expression.
            - The Elements of Programming Style (Kernighan & Plauger)


  parent reply	other threads:[~2021-11-29 17:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-29 15:31 Vincent Bernat
2021-11-29 16:34 ` Roman Perepelitsa
2021-11-29 17:44   ` Vincent Bernat
2021-11-29 16:50 ` Lawrence Velázquez
2021-11-29 17:03   ` Peter Stephenson
2021-11-29 17:43   ` Vincent Bernat [this message]
2021-11-29 17:45   ` Bart Schaefer
2021-11-29 19:43 ` 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=m3fsreeu2f.fsf@luffy.cx \
    --to=bernat@luffy.cx \
    --cc=larryv@zsh.org \
    --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).