mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
quick fix to reduce the number of logical negations, double meaning of "foo" and improve readability
@@ -50,9 +50,9 @@ foo=$(mycmd)
|
|||||||
The exit status of the command is overridden by the exit status of the creation of the local variable. For example:
|
The exit status of the command is overridden by the exit status of the creation of the local variable. For example:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ f() { local foo=$(false) || echo foo; }; f
|
$ f() { local foo=$(false) && echo "silent error happened"; }; f
|
||||||
$ f() { local foo; foo=$(false) || echo foo; }; f
|
silent error happened
|
||||||
foo
|
$ f() { local foo; foo=$(false) && echo "silent error happened"; }; f
|
||||||
```
|
```
|
||||||
|
|
||||||
### Problematic code in the case of `readonly`:
|
### Problematic code in the case of `readonly`:
|
||||||
|
Reference in New Issue
Block a user