zsh-workers
 help / color / mirror / code / Atom feed
* "${*:offset:length}" and ksh93/bash compatibility
@ 2022-03-10  7:50 Stephane Chazelas
  2022-03-10 12:48 ` Mikael Magnusson
  0 siblings, 1 reply; 11+ messages in thread
From: Stephane Chazelas @ 2022-03-10  7:50 UTC (permalink / raw)
  To: Zsh hackers list

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


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-03-23 10:23 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-10  7:50 "${*:offset:length}" and ksh93/bash compatibility 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

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