zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: Peter Stephenson <p.w.stephenson@ntlworld.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: "${*:offset:length}" and ksh93/bash compatibility
Date: Sun, 13 Mar 2022 16:22:09 +0100	[thread overview]
Message-ID: <CAHYJk3TTtr_4ib5rebTb+XicG1s0oEKcz8wAKdOcD2ztdOy8Xg@mail.gmail.com> (raw)
In-Reply-To: <7694652.296620.1646922350773@mail2.virginmedia.com>

On 3/10/22, Peter Stephenson <p.w.stephenson@ntlworld.com> wrote:
> On 10 March 2022 at 12:48 Mikael Magnusson <mikachu@gmail.com> wrote:
>> On 3/10/22, Stephane Chazelas <stephane@chazelas.org> wrote:
>> > Should zsh align with bash/ksh there.
>>
>> If we do, it would probably look something like this (does not handle
>> all cases), unless someone has a better idea...
>
> I think it should change --- the documentation is already clear this is
> here to please users of other shells, not native zsh.  Otherwise we end
> up with what's (as we say where I come from) neither nowt nor something.
>
>   This  syntax  gives  effects  similar to parameter subscripting in the
> form
>   $name[start,end], but is compatible with other shells; note that both
> off‐
>   set  and  length  are interpreted differently from the components of a
> sub‐
>   script.

I realized that this is not limited to $*,

zsh% a=(one two three); echo "${a[@]:0:2}"
one two
zsh% a=(one two three); echo "${a[*]:0:2}"
on
zsh% bash -c 'a=(one two three); echo "${a[@]:0:2}"'
one two
zsh% bash -c 'a=(one two three); echo "${a[*]:0:2}"'
one two

So perhaps this should be attacked in a different place/way than my
test patch (though i think the horrible offset hack is still needed
for $*:0 specifically (and i actually didn't even handle that in the
patch anyway.).)

-- 
Mikael Magnusson


  reply	other threads:[~2022-03-13 15:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-10  7:50 Stephane Chazelas
2022-03-10 12:48 ` Mikael Magnusson
2022-03-10 14:25   ` Peter Stephenson
2022-03-13 15:22     ` Mikael Magnusson [this message]
2022-03-13 18:21       ` Bart Schaefer
2022-03-13 19:23         ` Mikael Magnusson
2022-03-13 20:57           ` Bart Schaefer
2022-03-16  5:57       ` Jun T
2022-03-16 15:57         ` Mikael Magnusson
2022-03-23  8:08         ` Jun T
2022-03-23 10:23           ` Mikael Magnusson

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=CAHYJk3TTtr_4ib5rebTb+XicG1s0oEKcz8wAKdOcD2ztdOy8Xg@mail.gmail.com \
    --to=mikachu@gmail.com \
    --cc=p.w.stephenson@ntlworld.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).