Suppose I have a script like this:
command1 params command2 params command3 params
Now, as I understand, each of those commands will run independently of the return status of the previous one. But I want them all to run as a single transaction, i.e. if any previous command fails the script:
- should not proceed
- ideally revert actions done by previous commands
For the first question, I understand, that I can use
&& operator and chain all commands with it, or put if checks for
$? after each command, but are these approaches the only options?
And what is the standard approach for the second question?