Skip to content

SC2329 false positive when calling function via variable #3273

@MichaIng

Description

@MichaIng

For bugs with existing features

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

#!/bin/bash
func1(){ echo 'func1 called'; }
i=1
"func${i}"
exit 0

Here's what shellcheck currently says:

In test line 2:
func1(){ echo 'func1 called'; }
^-----------------------------^ SC2329 (info): This function is never invoked. Check usage (or ignored if invoked indirectly).

Here's what I wanted or expected to see:

Nothing, since the function is called. It might be expected behavior, similar to how function calls from traps are not recognized (yet), but at least the wiki does not mention it. There are other checks where shellcheck takes into account variables, so probably it is possible here as well for unconditionally assigned variables.

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