Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Inconsistencies in "-quoting and @-splitting, could someone elaborate?



On Sun, 28 Oct 2018 at 02:34, dana <dana@xxxxxxx> wrote:

> >accidentally-similar, with possible further differences, exceptions,
> >so I would state there's a major inconsistency/historically-driven
> >problem in Zsh. Are there other such flags in Zsh?
>
> I don't understand where the inconsistency is...? Are you just speculating that
> there might be one?

@ is refered to as "@  -- double-quoted splitting of scalars" in
completion. I understand it as: for quoted expression, regenerate
array-form by doing splitting. So "$array" is a single string
containing the whole array contents (if not ksharrays, where it would
have only 1st element), while "${(@)array}" is still an array, because
theoretically, like the completion says, the "-induced string is split
to again become an array.

So one can obtain always-array behavior with @. This flag doesn't help
(s::) and (z) when the result is string. I feel this is inconsistent,
I should be able to "split" the resulting string into an array, like
it would happen here with @ and array:

% array=( "foo" )
% print "${#${(@)array}}"
1

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.

-- 
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