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

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



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