When run on this script
#!/bin/bash
declare -A arr=()
declare -p arr
arr[k1]=lfkej
declare -p arr
# Silence SC2034 warning about arr being unused.
: "${arr[@]}"
shellcheck reports
In arr.sh line 6:
arr[k1]=lfkej
^-- SC2154: k1 is referenced but not assigned.
but arr is an associative array and the contents of [] for them are not arithmetically evaluated.
I can verify this. I worked around it by declaring inline:
declare -A array=( [k1]=lfkej )
Nice work-around @pbiggar, I confirm it works, thanks!
I have same problem
2 @pbiggar - inline declare breaks readability in big arrays(
@strizhechenko
but you can improve readability like this:
#color matching criteria (case insensitive)
declare -A colorm=(
[red]="red"
[orange]="orange"
[yellow]="yellow"
[green]="green"
[blue]="blue"
[black]="black"
[violet]="violet\|purple\|magenta\|pink"
[all]="all of \(the above\|them\)"
)
Fixed in 07fd5724
Awesome, thanks!
Most helpful comment
Fixed in 07fd5724