Skip to content

check for readonly variables within loops #3089

@robstoll

Description

@robstoll

For new checks and feature suggestions

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

foo() {
  while read -r -d $'\0' file; do
    local -r someVar="..."
  done
}

Here's what shellcheck currently says:

nothing

Here's what I wanted or expected to see:

readonly variable within a loop is smelly as it will fail if the loop is executed more than once

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