5 ms·
Agree, but be aware of subshells, these options don't propagate there. $ set -eu $ echo "$(false)" $
by leni536 10y ago
Agree, but be aware of subshells, these options don't propagate there.
$ set -eu
$ echo "$(false)"
$
- teaearlgraycold 10y ago#!/bin/bash set -eu export SHELLOPTS
- harryjo 10y agoThat doesn't solve the problem that parent incorrectly explained. echo "$(false)" swallows the exit code from $(false). $ cat /tmp/test.sh set -euvx export SHELLOPTS echo "$(false)" echo "echo of string with failed subcommand does not kill script" $(false) echo "but consuming exit code does" $ /tmp/test.sh export SHELLOPTS + export SHELLOPTS echo "$(false)" false ++ false + echo '' echo "echo of string with failed subcommand does not kill script" + echo 'echo of string with failed subcommand does not kill script' echo of string with failed subcommand does not kill script $(false) false ++ false
- Slackwise 10y agoThese are the kinds of pitfalls, aside from everything else in this thread, that make me just use Ruby for scripting instead. I mean, I can always just backtick pipe anything that would be convenient but avoid this nonsense.