Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ls -al file.ext
- rc=$?
- if [[ $rc != 0 ]] ; then
- exit $rc
- fi
- ls -al file.ext | sed 's/^/xx: /"
- set -e
- set -o pipefail
- command1 && command2 && command3
- command1 && command2 && command3
- if command1
- then
- if command2
- then
- do_something
- else
- exit
- fi
- else
- exit
- fi
- # this will trap any errors or commands with non-zero exit status
- # by calling function catch_errors()
- trap catch_errors ERR;
- #
- # ... the rest of the script goes here
- #
- function catch_errors() {
- # do whatever on errors
- #
- #
- echo "script aborted, because of errors";
- exit 0;
- }
- [ $? -eq 0 ] || exit($?) # exit for none-zero return code
Add Comment
Please, Sign In to add comment