I am currently using something like this:
( false true ) && echo "OK" || echo "FAILED";
And it does not work. I would like the subshell to go out with an error if something doesnβt work out (in this case itβs a lie). Currently, it fails if the last command does not work.
It should exit only from the current subshell, and not from the whole script.
I pass this script on to people and I don't want them to see all the output, but still give them some kind of answer if the script was successful or not.
Edit: The commands inside the subcircuit above are just an example. I would like to run several commands inside a subshell without checking the return value after each command . Something like set -e for subshells.
Edit2: I tried adding set -e inside the subshell. Maybe I did something wrong, but that did not change the behavior of my script. This did not stop the execution or exit from the subshell with a non-0 code.
( set -e false echo "test" ) && echo "OK" || echo "FAILED";
The test prints first, and then OK. It must print FAILED due to false.
Lorof source share