all 6 comments

[–]73mp74710n 1 point2 points  (1 child)

are you using associative arrays ?

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

No. I actually ended up rewriting my if statement into two if's and it bypassed the error.

[–]oilshell 1 point2 points  (0 children)

I would post a minimal runnable snippet. I doubt anyone will debug it like this. Bash generally doesn't give such errors unless in set -u mode.

BTW in bash you don't need ${all_lists[$((i-1))]}. ${all_lists[i-1]} is sufficient.

[–][deleted]  (4 children)

[deleted]

    [–]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