Re: Feature request: index of index

2021-06-22 Thread Phi Debian
Meanwhile you may use functions to setup your variables something along those lines. PW$ function first-index { echo $1; } PW$ function last-index { shift $(($#-1)) ; echo $1; } PW$ declare -a array=([5]="hello" [11]="world" [42]="here") PW$ declare -i first_index=$(first-index ${!array[@]}) PW$

Feature request: index of index

2021-05-06 Thread Léa Gris
Currently, to know the index of an array's indexes (example: first or last index), it needs an intermediary index array: #!/usr/bin/env bash declare -a array=([5]=hello [11]=world [42]=here) declare -ai indexes=("${!array[@]}") declare -i first_index=${indexes[*]:0:1} declare -i last_index=${i