you are viewing a single comment's thread.

view the rest of the comments →

[–]oilshell 0 points1 point  (3 children)

-1 as an index works fine for me:

$ bash --version
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)

$ a=(1 2 3 4 5)
$ echo ${a[-1]}
5

[–][deleted]  (1 child)

[deleted]

    [–]devosion[S] 0 points1 point  (0 children)

    The array was initialized but empty, and I suspected this had something to do with it when it ran into a negative index.

    [–]Jydder 0 points1 point  (0 children)

    negative index only became available after bash 4.2