mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Note about exit code
@@ -18,7 +18,9 @@ cat 1.txt # In bash, but faster and still sticks exactly one newline: printf '%s
|
||||
|
||||
### Rationale
|
||||
|
||||
The command substitution `$(foo)` yields the result of command `foo` with trailing newlines erased, and when it is passed to `echo` it generally just gives the same result as `foo`.
|
||||
The command substitution `$(foo)` yields the result of command `foo` with trailing newlines erased, and when it is passed to `echo` it generally just gives the same result as `foo`.
|
||||
|
||||
The command `echo "$(false)"` will return true, whereas `false` of course returns false – beware of the ignored exit code before blindly altering scripts. If using `set -e`, the correct substitution of `echo "$(cmd)"` would be `cmd || true`.
|
||||
|
||||
### Exceptions
|
||||
|
||||
|
Reference in New Issue
Block a user