Inconsistency between how subscripting works with the @ array vs. an act
From:
Stan Marsh
Subject:
Inconsistency between how subscripting works with the @ array vs. an actual array
Date:
Sun, 10 May 2026 14:09:51 -0600
Observe:
--- Cut Here ---
$ set -- one two three
$ echo $#
3
$ printf "%s\n" "$@"
one
two
three
$ printf "%s\n" "${@:0}"
bash53
one
two
three
$ printf "%s\n" "${@:1}"
one
two
three
$ printf "%s\n" "${@:2}"
two
three
$
--- Cut Here ---
Now imagine doing this exercise over with an indexed array. I.e., start with:
$ unset A;A=(one two three)
See the difference?
And note that my specific complaint is that ${@:1} should skip the
first element (i.e., start with the second one), but it does not.
You have to (non-intuitively) code ${@:2} to start with the second
element.
Another way to see this is that $@ and ${@:1} give the same result.
=================================================================================
Please do not send me replies to my posts on the list.
I always read the replies via the web archive, so CC'ing to me is unnecessary.
When responding to my posts, please try to refrain from giving bureaucratic
answers. If you have nothing useful to say, then just click Next and go on.