Returning value from called function in a shell script

后端 未结 5 518
自闭症患者
自闭症患者 2020-11-27 08:55

I want to return the value from a function called in a shell script. Perhaps I am missing the syntax. I tried using the global variables. But that is also not working. The c

5条回答
  •  一生所求
    2020-11-27 09:52

    If it's just a true/false test, have your function return 0 for success, and return 1 for failure. The test would then be:

    if function_name; then
      do something
    else
      error condition
    fi
    

提交回复
热议问题