On Fri, Jun 06, 2008 at 10:38:41AM +0200, Andreas Schwab wrote: > Stephane Chazelas <[EMAIL PROTECTED]> writes: > > > The behavior is the same in ksh, but in ksh ${@:0:1} expands to > > $0 which makes it more understandable ($0 has its meaning in > > functions as well in ksh which makes it somehow consistent). > > > > In bash, ${@:0:1} and ${@:1:1} expand to the same thing ($1). Is > > all that documented (I couldn't find it via a quick scan of the > > man page)? > > $@ expands to the positional parameters, which $0 is not (it is a > special parameter). Since index 0 does not exist, $1 is the first > counted parameter in the expansion. [...]
You make me remember that I had forgotten that aspect of ksh and bash arrays in that they are associative arrays (contrary to zsh's) with keys being only positive of null integers. ${a[0]} is the element of key 0. [EMAIL PROTECTED]:0:1} is the first element of the list of $a elements numerically sorted by their keys. And [EMAIL PROTECTED]:1:1} is the second element. It still doesn't explain why ${@:1:1} expands to $1 and not $2 (if we assume that $0 is not part of $@ which I agree). -- Stéphane