I am running a command. In case of failure part after || would be executed. It would also be executed in case of timeout.
$ timeout 5 script.sh || { echo "Would execute if timeout or script failure"; }
How can I handle timeout error and script error separately?
$ timeout 5 script.sh ??? { echo "Timeout is fine, but this is printed only if script.sh returns an error"; }
timeoutcommand is 124; you can use it to distinguish the type of error but this is not really reliable since there's no way telling the difference if the script itself returns 124