I have a unix script in which I am calling functions. I want the function should return immediately if any of the command failed in between.
But checking $? after every command I can not do. Is there any other way to do this.
I have a unix script in which I am calling functions. I want the function should return immediately if any of the command failed in between.
But checking $? after every command I can not do. Is there any other way to do this.
This is another idea after my previous answer. It works with bash script and requires your functions to be quite simple (pipes may cause some issues):
Furthermore: functions need to be external command (this is why I use
/bin/echo
rather thanecho
). Regards.