Setting bash flags in subshells - does it affect parent shell?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have this in a bash script:
(
set -o pipefail
echo "foobar" | bash
set +o pipefail
)
do I need to reset pipefail setting, or can I just omit that line? In other words, does the pipefail setting in the subshell affect the parent?
So that means I assume that this:
(
set -o pipefail
echo "foobar" | bash
)
is really no different than the above?
bash shell-script subshell pipefail
add a comment |Â
up vote
0
down vote
favorite
I have this in a bash script:
(
set -o pipefail
echo "foobar" | bash
set +o pipefail
)
do I need to reset pipefail setting, or can I just omit that line? In other words, does the pipefail setting in the subshell affect the parent?
So that means I assume that this:
(
set -o pipefail
echo "foobar" | bash
)
is really no different than the above?
bash shell-script subshell pipefail
they probably aren't called bash flags / settings...if you can correct me on the terminology that would be good
â Alexander Mills
May 7 at 21:52
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have this in a bash script:
(
set -o pipefail
echo "foobar" | bash
set +o pipefail
)
do I need to reset pipefail setting, or can I just omit that line? In other words, does the pipefail setting in the subshell affect the parent?
So that means I assume that this:
(
set -o pipefail
echo "foobar" | bash
)
is really no different than the above?
bash shell-script subshell pipefail
I have this in a bash script:
(
set -o pipefail
echo "foobar" | bash
set +o pipefail
)
do I need to reset pipefail setting, or can I just omit that line? In other words, does the pipefail setting in the subshell affect the parent?
So that means I assume that this:
(
set -o pipefail
echo "foobar" | bash
)
is really no different than the above?
bash shell-script subshell pipefail
asked May 7 at 21:51
Alexander Mills
1,885929
1,885929
they probably aren't called bash flags / settings...if you can correct me on the terminology that would be good
â Alexander Mills
May 7 at 21:52
add a comment |Â
they probably aren't called bash flags / settings...if you can correct me on the terminology that would be good
â Alexander Mills
May 7 at 21:52
they probably aren't called bash flags / settings...if you can correct me on the terminology that would be good
â Alexander Mills
May 7 at 21:52
they probably aren't called bash flags / settings...if you can correct me on the terminology that would be good
â Alexander Mills
May 7 at 21:52
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
To quote the man page:
Changes made to the subshell environment cannot affect the shell's execution environment.
You can test your case easily:
$ set +o pipefail
$ (set -o pipefail)
$ shopt -o | grep pipefail
pipefail off
Yeah that's what I though, so no need to unset things at the end of the subshell I guess
â Alexander Mills
May 7 at 23:00
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
To quote the man page:
Changes made to the subshell environment cannot affect the shell's execution environment.
You can test your case easily:
$ set +o pipefail
$ (set -o pipefail)
$ shopt -o | grep pipefail
pipefail off
Yeah that's what I though, so no need to unset things at the end of the subshell I guess
â Alexander Mills
May 7 at 23:00
add a comment |Â
up vote
2
down vote
To quote the man page:
Changes made to the subshell environment cannot affect the shell's execution environment.
You can test your case easily:
$ set +o pipefail
$ (set -o pipefail)
$ shopt -o | grep pipefail
pipefail off
Yeah that's what I though, so no need to unset things at the end of the subshell I guess
â Alexander Mills
May 7 at 23:00
add a comment |Â
up vote
2
down vote
up vote
2
down vote
To quote the man page:
Changes made to the subshell environment cannot affect the shell's execution environment.
You can test your case easily:
$ set +o pipefail
$ (set -o pipefail)
$ shopt -o | grep pipefail
pipefail off
To quote the man page:
Changes made to the subshell environment cannot affect the shell's execution environment.
You can test your case easily:
$ set +o pipefail
$ (set -o pipefail)
$ shopt -o | grep pipefail
pipefail off
answered May 7 at 22:51
Grisha Levit
20116
20116
Yeah that's what I though, so no need to unset things at the end of the subshell I guess
â Alexander Mills
May 7 at 23:00
add a comment |Â
Yeah that's what I though, so no need to unset things at the end of the subshell I guess
â Alexander Mills
May 7 at 23:00
Yeah that's what I though, so no need to unset things at the end of the subshell I guess
â Alexander Mills
May 7 at 23:00
Yeah that's what I though, so no need to unset things at the end of the subshell I guess
â Alexander Mills
May 7 at 23:00
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f442414%2fsetting-bash-flags-in-subshells-does-it-affect-parent-shell%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
they probably aren't called bash flags / settings...if you can correct me on the terminology that would be good
â Alexander Mills
May 7 at 21:52