Skip to content

name reference variables should not be checked for SC2178 #3417

@nilsonaj

Description

@nilsonaj

For bugs

  • Rule Id (if any, e.g. SC1000): SC2178
  • My shellcheck version (shellcheck --version or 'online'): online
  • I tried on shellcheck.net and verified that this is still a problem on the latest commit
  • It's not reproducible on shellcheck.net, but I think that's because it's an OS, configuration or encoding issue

For new checks and feature suggestions

Here's a snippet or screenshot that shows the problem:

#!/usr/bin/env bash
function rmfg_get_info()
{
    local _hash_name_=${1}
    local -n _hash_name_ref_="${_hash_name_}"
    _hash_name_ref_["iface"]="eth0"
}


function rmfg_get_other_info()
{
    local _hash_name_=${1}
    local -n _hash_name_ref_="${_hash_name_}"
    _hash_name_ref_["iface"]="wlan0"
}
declare -xgA hash=()
declare -xgA other_hash=()
rmfg_get_info hash
rmfg_get_other_infh other_hash

Here's what shellcheck currently says:

Line 13	SC2178: Variable was used as an array but is now assigned a string.

Here's what I wanted or expected to see:

Since this variable is a reference, it should not be checked for this problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions