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

Re: "${*:offset:length}" and ksh93/bash compatibility



Arriving to this a bit late, have been traveling.

On Sun, Mar 13, 2022 at 8:22 AM Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>
> zsh% a=(one two three); echo "${a[*]:0:2}"
> on
> zsh% bash -c 'a=(one two three); echo "${a[*]:0:2}"'
> one two

The [*] subscript in double quotes has always been treated differently
in zsh.  You need [@] or the (@) modifier to preserve array-ness.  I'm
not sure the presence of the :off:len suffix should change that as a
side-effect, at least not in native zsh mode ... and it might be
difficult to "notice" the suffix early enough in the expansion code to
cause that effect anyway.  Particularly without also having the effect
that the end result is not joined into a single string.




Messages sorted by: Reverse Date, Date, Thread, Author