-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Description
- My shellcheck version (
0.11.0and "online"): - The rule's wiki page does not already cover this
- I tried on https://www.shellcheck.net/
Here's a snippet or screenshot that shows the problem:
#!/bin/bash
declare i=0
declare -A arr_123=()
declare -n arr=arr_123
arr+=([${i}]="$i")
echo "${arr[${i}]}"Here's what shellcheck currently says:
In test.sh line 4:
declare -A arr_123=()
^-----^ SC2034 (warning): arr_123 appears unused. Verify use (or export if used externally).
In test.sh line 7:
arr+=([${i}]="$i")
^--^ SC2004 (style): $/${} is unnecessary on arithmetic variables.
And when I change to just [i] behavior changes too.
Also I have issue with SC2178 on declare -n that I can't reproduce in test script for now.
In scr line 895:
declare -n array_inscr="array_inscr_${i}" # Array was declared with `-a`
^---------^ SC2178 (warning): Variable was used as an array but is now assigned a string.Here's what I wanted or expected to see:
No warnings when used without a reference.
#!/bin/bash
declare i=0
declare -A arr_123=()
#declare -n arr=arr_123
arr_123+=([${i}]="$i")
echo "${arr_123[${i}]}"jeremiejig
Metadata
Metadata
Assignees
Labels
No labels