Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
"${*:offset:length}" and ksh93/bash compatibility
- X-seq: zsh-workers 49819
- From: Stephane Chazelas <stephane@xxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: "${*:offset:length}" and ksh93/bash compatibility
- Date: Thu, 10 Mar 2022 07:50:26 +0000
- Archived-at: <https://zsh.org/workers/49819>
- List-id: <zsh-workers.zsh.org>
- Mail-followup-to: Zsh hackers list <zsh-workers@xxxxxxx>
Hello,
From workers/28418 I understand the ${param:offset:length} was
introduced only for compatibility with bash (though the feature
was initially from ksh93) as zsh already had $param[first,last]
(long before bash had arrays or ksh93 even existed).
Still, there's a difference with ksh/bash when
${*:offset:length} (same for ${array[*]}) is quoted:
$ zsh --emulate ksh -c 'printf "<%s>\n" ${*:1:2}' zsh foo bar baz
<foo>
<bar>
$ zsh --emulate ksh -c 'printf "<%s>\n" "${*:1:2}"' zsh foo bar baz
<oo>
$ ksh -c 'printf "<%s>\n" ${*:1:2}' ksh foo bar baz
<foo>
<bar>
$ ksh -c 'printf "<%s>\n" "${*:1:2}"' ksh foo bar baz
<foo bar>
$ bash -c 'printf "<%s>\n" ${*:1:2}' ksh foo bar baz
<foo>
<bar>
$ bash -c 'printf "<%s>\n" "${*:1:2}"' ksh foo bar baz
<foo bar>
Should zsh align with bash/ksh there.
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author