shellcheck
shellcheck copied to clipboard
Readonly reassignment
For new checks and feature suggestions
- [x] https://www.shellcheck.net/ (i.e. the latest commit) currently gives no useful warnings about
- [x] I searched through https://github.com/koalaman/shellcheck/issues and found related #1287
Here's a snippet or screenshot that shows the problem:
#!/bin/sh
readonly a=Hello
a="$a World"
Here's what shellcheck currently says:
Nothing.
Here's what I wanted or expected to see:
Line 3:
a="$a World"
^-- SCXXXX Variable "a" is set as read-only.
another example
#!/usr/bin/env bash
declare -r textA='readonly'
declare textB='appended'
textA+=",${textB}"