Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Inconsistencies in "-quoting and @-splitting, could someone elaborate?
- X-seq: zsh-workers 43738
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: Inconsistencies in "-quoting and @-splitting, could someone elaborate?
- Date: Sun, 28 Oct 2018 16:45:41 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-transfer-encoding; bh=TsDHC9u6zIXukghDdmAtT7FlIic9/StLXn8IYk/PC4k=; b=TeSKJd44soEw0Ov4t2ZEjSwnHEo7J0TzkhbCy4snKp3LFh0uRzwhqq0PM5S+EiLr/O rV3pB5FnsQ42IXhJXxRKSNWaw7JaA5lOWfWH+2KzLICTNtC7d7+Q0VEFmxH64AxUIW0o Cl1lrMx+Gb2ZgNfGsWmrvZl/H3r6Z1EUtMqJVu0W8FrW4DO6Foi27L08RCxlc/DRk6Uk 6G790oNUau7HmQhdf3Veb7xzei5AX+yegmLqfKE0CWPMWGT5QapiR1+0QjSVXpGXHeKA w2BdH01sR3QDZrrCZKJ0RKAB5tmlzuC3yqFyeE2wr/UlZZob9vdg/2OP4mDuD9vOnWiq K6TQ==
- In-reply-to: <CAKc7PVBWSeSna03nsPnXutEQ4Q8gw0=wLkNZ0-gPhbgsg9dBbw@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVCdqYwOrYr5-7bzduNsJd9OAUz0B-68jg_D5MqMUiVnKw@mail.gmail.com> <1BE52C46-161F-412B-A539-4B0EA87A2FCE@dana.is> <CAKc7PVAReJOH_T24hZ3qEMpyZGaXat3Ak7muYg9vJEC6HZKhag@mail.gmail.com> <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@xxxxxxxxx> wrote:
>
> On Sun, 28 Oct 2018 at 12:54, Sebastian Gniazdowski
> <sgniazdowski@xxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author