Бэш попробуй поймать

{
# Try
} || {
# Executed when above fails
}
{
# Do stuff
} && {
# Only executed when above worked
}
Pi3141