zsh-workers
 help / color / mirror / code / Atom feed
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Inconsistencies in "-quoting and @-splitting, could someone elaborate?
Date: Sun, 28 Oct 2018 16:45:41 +0100	[thread overview]
Message-ID: <CAKc7PVAzH8SNAwT-YkWy3rFg4Fezhgq4Ark2brH4FuCrBsiOMA@mail.gmail.com> (raw)
In-Reply-To: <CAKc7PVBWSeSna03nsPnXutEQ4Q8gw0=wLkNZ0-gPhbgsg9dBbw@mail.gmail.com>

PS. I'm not examining this to induce some changes in Zsh – I think
every project can have bunch of its distinct traits, non-symmetrical –
but to gain more knowledge and maybe get information about other flags
like z&s, to provide a possibly clear paragraph about exceptions in
the document "Zsh Native Scripting Handbook". It currently follows "@
is double-quoted splitting" based on completion-description and some
insight/revelations, and it's too optimistic, doesn't describe
exceptions.
On Sun, 28 Oct 2018 at 16:41, Sebastian Gniazdowski
<sgniazdowski@gmail.com> wrote:
>
> On Sun, 28 Oct 2018 at 12:54, Sebastian Gniazdowski
> <sgniazdowski@gmail.com> wrote:
> > Despite array is single element, @ splits it into array type. (s::)
> > and (z) behave differently for single-element result, that is one
> > (maybe subjective) inconsistency, and for the second – @ doesn't help
> > (ie. (z@) still doesn't return as an array), that's second
> > inconsistency IMO.
>
> I've forgot one inconsistency and thought that a more explicit
> description of them (of the (subjective) inconsistencies) can be
> provided:
>
> 1.a) array=( "foo" ); print "${#${(@)array}}" -> 1
> 1.b) words="singleword"; print "${#${(z)words}}" -> 10
> 1.description) with @, it is possible to obtain "always-array"
> behavior, while (z) and (s::) have exceptions and not always return
> arrays (one could think that if a flag takes the responsibility for
> splitting in string-context ("-quoted), then that it will mimic the
> first tool to do that, the @)
>
> 2.a) the same as 1.a
> 2.b) words="singleword"; print "${#${(z@)words}}" -> 10
> 2.description) if ${(@)array} makes single-element quoted array back
> an array again, then shouldn't @ acting on single-element data (Bart
> said it's not array) returned by (z)/(s::) also make it an array
> again?
>
> 3.a) array=( "foo" "bar" ); print -rl "$array" -> foo bar # both
> elements in one line, signaling the expected "scalarization"
> 3.b) words="two words"; print -rl "${(z)words}" -> foo\nbar # two
> lines, with one word each, indicating non-scalar result
> 3.c) words="two words"; print -rl "${(s: :)words}" -> foo\nbar # --- " ---
> 3.description) Basically, the general method of Zshell to obtain
> scalars with no splits – double-quoting – isn't followed by (z) and
> (s::) flags. The manuals often elaborate about some situations and
> "-quoting like if this would be a general "scalarization" method
> guaranteed by Zsh design. Hard to give examples, but maybe this one:
>
>     ${name:|arrayname}
>               ... If the substitution is scalar, either because
>               name is a scalar variable >>or the expression is
> quoted<<, the elements of arrayname are instead  tested
>               against the entire expression.
>
> Above slightly suggests "-quoting as a general method for obtaining scalars.
> --
> Sebastian Gniazdowski
> News: https://twitter.com/ZdharmaI
> IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
> Blog: http://zdharma.org



-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org

  reply	other threads:[~2018-10-28 15:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-27 10:33 Sebastian Gniazdowski
2018-10-28  0:34 ` dana
2018-10-28  4:54   ` Bart Schaefer
2018-10-28 11:54   ` Sebastian Gniazdowski
2018-10-28 15:41     ` Sebastian Gniazdowski
2018-10-28 15:45       ` Sebastian Gniazdowski [this message]
2018-10-28 21:20       ` Bart Schaefer
2018-10-28 21:12     ` Bart Schaefer
2018-10-29  9:10       ` Sebastian Gniazdowski
2018-10-29 15:24         ` Bart Schaefer
2018-11-05 19:03           ` Sebastian Gniazdowski
2018-11-05 23:20             ` 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=CAKc7PVAzH8SNAwT-YkWy3rFg4Fezhgq4Ark2brH4FuCrBsiOMA@mail.gmail.com \
    --to=sgniazdowski@gmail.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).