Skip to content

printf -v 'array[0]' does not count as array assignment #896

@koalaman

Description

@koalaman

For bugs

  • Rule Id (if any, e.g. SC1000): SC2154
  • 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

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

#!/bin/bash
var=howdy;
printf -v 'array[0]' %s "$var";
printf %s\\n "${array[@]}";

Here's what shellcheck currently says:

Line 4:
printf %s\\n "${array[@]}";
              ^-- SC2154: array is referenced but not assigned.

Here's what I wanted or expected to see:

Nothing

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