How to exit a function in bash

前端 未结 3 1771
猫巷女王i
猫巷女王i 2021-01-30 15:18

How would you exit out of a function if a condition is true without killing the whole script, just return back to before you called the function.

Example



        
3条回答
  •  失恋的感觉
    2021-01-30 15:58

    Use return operator:

    function FUNCT {
      if [ blah is false ]; then
        return 1 # or return 0, or even you can omit the argument.
      else
        keep running the function
      fi
    }
    

提交回复
热议问题