On Mon, Oct 15, 2012 at 11:23 AM, Nikolai Kondrashov <nikolai.kondras...@redhat.com> wrote: > Hi everyone, > > I've noticed that errexit is disabled inside command substitution. > Is this intentional? > > It makes it hard to save and restore errexit state. I.e. you can't simply > say > opts=`set +o`, because errexit will always be stored as off. What's > interesting, $SHELLOPTS shows it still on inside the command substitution. > > Sincerely, > Nick >
I'm also not entirely sure what you mean by "errexit will always be stored as off." set -e; set +o # gives me: set +o allexport set -o braceexpand set +o emacs set -o errexit set +o errtrace set +o functrace set -o hashall set +o histexpand set -o history set +o ignoreeof set -o interactive-comments set +o keyword set -o monitor set +o noclobber set +o noexec set +o noglob set +o nolog set +o notify set +o nounset set +o onecmd set +o physical set +o pipefail set +o posix set +o privileged set +o verbose set -o vi set +o xtrace It's on there... Do you not understand that command substitution creates a subshell? What is the goal/problem that you're trying to solve?