In Linux Mint 22.3 (Cinnamon/GNOME Terminal), if you want to stop execution of pasted commands as soon as one fails (exits with a non-zero code), but without closing the terminal or writing a script, you have a few options.
set -e Doesn't Work for Youset -e (or set -o errexit) causes the shell to exit immediately if any command fails.set -eYou can wrap your pasted commands in a subshell with set -e:
bash(set -e; command1; command2; command3; ...)
bash(set -e; ls /nonexistent; echo "This won't run if ls fails")
ls /nonexistent fails, the echo command is skipped, but your terminal stays open.&& Between CommandsIf you paste commands like this:
bashcommand1 && command2 && command3
&& between commands), but it works in an interactive shell.set -e).set -e(set -e; cmd1; ...)cmd1 && cmd2&&)Recommendation:
Use the subshell approach ((set -e; ...)) for the closest match to your needs. It’s a one-liner, requires no script file, and keeps your terminal open.
Question: Would you like a way to make this even more convenient (e.g., with a shell function or alias)?