Provide rationale for SC2155 in the case of local as explained by @jgallag88 in delphix/appliance-build#339

Basil Crow
2019-07-25 12:02:48 -07:00
parent 74adeb1d5a
commit 9287ec9bc7

@@ -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