zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: Jun T <takimoto-j@kba.biglobe.ne.jp>
Cc: zsh-workers@zsh.org
Subject: Re: "${*:offset:length}" and ksh93/bash compatibility
Date: Wed, 23 Mar 2022 11:23:11 +0100	[thread overview]
Message-ID: <CAHYJk3RNnKip2A+LwnJMaxA13ywLEgvjbs9mP1c=bbJzKoO_Eg@mail.gmail.com> (raw)
In-Reply-To: <71CBB202-36EA-44A8-A225-408C87101E70@kba.biglobe.ne.jp>

On 3/23/22, Jun T <takimoto-j@kba.biglobe.ne.jp> wrote:
>
>> 2022/03/16 14:57, I wrote:
>>
>> The following patch seems to work for
>> "${*:1:2}"   "${@:1:2}"  "$a[@]:0:2}"  "${a[*]:0:2}"
>
> This is a test for the patch.
>
>
> diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
> index b6b1f2e33..20f731dcb 100644
> --- a/Test/D04parameter.ztst
> +++ b/Test/D04parameter.ztst
> @@ -1693,6 +1693,30 @@
>  >b
>  >c
>
> +   () {
> +     emulate -L sh
> +     local a=( one two three )
> +     printf '<%s><%s>\n' ${a[*]:0:2}
> +     printf '<%s><%s>\n' "${a[*]:0:2}"
> +     printf '<%s><%s>\n' ${a[@]:0:2}
> +     printf '<%s><%s>\n' "${a[@]:0:2}"
> +     printf '<%s><%s>\n' "${a:0:2}"
> +     printf '<%s><%s>\n' ${*:1:2}
> +     printf '<%s><%s>\n' "${*:1:2}"
> +     printf '<%s><%s>\n' ${@:1:2}
> +     printf '<%s><%s>\n' "${@:1:2}"
> +   } one two three
> +0:Bash-style offsets, quoted array
> +><one><two>
> +><one two><>
> +><one><two>
> +><one><two>
> +><on><>
> +><one><two>
> +><one two><>
> +><one><two>
> +><one><two>
> +
>     printf "%n" '[0]'
>  1:Regression test for identifier test
>  ?(eval):1: not an identifier: [0]

I think the test should include
 +     printf '<%s><%s>\n' ${*:0:2}
 +     printf '<%s><%s>\n' "${*:0:2}"
 +     printf '<%s><%s>\n' ${@:0:2}
 +     printf '<%s><%s>\n' "${@:0:2}"
as well, since 0 is handled specially (the horrible offset hack).

-- 
Mikael Magnusson


      reply	other threads:[~2022-03-23 10:23 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
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 [this message]

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='CAHYJk3RNnKip2A+LwnJMaxA13ywLEgvjbs9mP1c=bbJzKoO_Eg@mail.gmail.com' \
    --to=mikachu@gmail.com \
    --cc=takimoto-j@kba.biglobe.ne.jp \
    --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).