Note about exit code

Kevin Brubeck Unhammer
2020-10-24 09:20:18 +02:00
parent 14af6dc0e8
commit f910995c0b

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