For a cheap way to handle errors in a Bash script, you can take advantage of the fact that Bash will only test the first condition in an "OR" statement if the first statement is true. The only way the second condition will be tested is if the first condition is false (see table below)
true or true = true true or false = true false or true = true false or false = falseThis means we can put our command to be executed as the first condition and our command to be executed upon failure to be our second condition. If our command to be executed succeeds (returns a true value) then the error handling command won't be executed, otherwise it will. The following is an example.
ls /etc/duane 2> /dev/null || echo "error" | osd_cat -p middle -A centerIn the example above I also directed stderr to /dev/null so we won't see any bad output from the failed command. My error handling routine really just uses X on-screen display to show the word "error" overlayed in the middle of our desktop.
![[logo]](logo.png)