mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Provide rationale for SC2155 in the case of local
as explained by @jgallag88 in delphix/appliance-build#339
10
SC2155.md
10
SC2155.md
@@ -43,6 +43,16 @@ local foo
|
|||||||
foo=$(mycmd)
|
foo=$(mycmd)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Rationale
|
||||||
|
|
||||||
|
The exit status of the command is overridden by the exit status of the creation the local variable. For example:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ f() { local foo=$(false) || echo foo; }; f
|
||||||
|
$ f() { local foo; foo=$(false) || echo foo; }; f
|
||||||
|
foo
|
||||||
|
```
|
||||||
|
|
||||||
### Problematic code in the case of `readonly`:
|
### Problematic code in the case of `readonly`:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
Reference in New Issue
Block a user