Skip to content

SC3043?: local with options is bashism #3395

@e-kwsm

Description

@e-kwsm

For bugs

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

#!/bin/dash
#shellcheck disable=SC2034
f() {
        local -r var=foo
}

Here's what shellcheck currently says:

nothing

Here's what I wanted or expected to see:

dash does not support -r and other options:

$ f() { local -r var=foo; }
$ f
dash: 1: local: -r: bad variable name
-:4:2: error: In dash, 'local' accepts no option. [SC3043]

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