bun icon indicating copy to clipboard operation
bun copied to clipboard

Bun shell should provide a way to do something similar to 'set -euo pipefail' in bash

Open wollowizard opened this issue 8 months ago • 1 comments

What is the problem this feature would solve?

In bun shell, if I have 2 instructions on 2 lines, the return code of the first is always ignored (which is also the case in bash), so execution proceeds to the second instruction

try {
    await $`cat non-existent-directory 
    echo " This should not be printed?"`
} catch (e) {
    console.log("error");
}

but it would be nice to have a behavior similar to set -euo pipefail (maybe by default or at least opt-in).

What is the feature you are proposing to solve the problem?

Provide a way, either by default or opt-in, to have something similar to set -euo pipefail in bash

What alternatives have you considered?

can be solved with && for example

await $`cat non-existent-directory && echo " This should not be printed?"`

but if there are 5+ long instructions, this is very cumbersome

wollowizard avatar Jun 12 '24 10:06 wollowizard