mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Add problematic/correct examples for readonly declarations
13
SC2155.md
13
SC2155.md
@@ -41,4 +41,17 @@ local foo="$(mycmd)"
|
|||||||
```sh
|
```sh
|
||||||
local foo
|
local foo
|
||||||
foo=$(mycmd)
|
foo=$(mycmd)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Problematic code in the case of `readonly`:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
readonly foo="$(mycmd)"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Correct code:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
foo="$(mycmd)"
|
||||||
|
readonly foo
|
||||||
```
|
```
|
Reference in New Issue
Block a user