Fix set -e
for conditionals
When porting scripts to Ion I noticed that using set -e
scripts would exit early even when conditions fail. This is in contrast to common shells like Bash which has a list of exceptions exactly for this case.
Approach
In this PR I've tried to tackle the problem in the most naive way:
- keep creating
PipelineError::EarlyExit
to "capture intent" - prevent result/error propagation for
PipelineError::EarlyExit
in certain locations - re-raise if necessary
I've also added specific test cases to test proper behavior and copied tests for conditionals to also test with set -e
.
Known Problems
- I've currently no idea how to ignore failing subshells in conditions ( see
if ! $(false | true) ...
below)
Please feel free to rewrite my PR or find a better approach to this issue.