How to call a function in shell Scripting?

后端 未结 7 1063
情话喂你
情话喂你 2020-12-05 05:06

I have a shell script which conditionally calls a function.

For Example:-

if [ \"$choice\" = \"true\" ]
then 
  process_install
elif [ \"$choice\" =          


        
7条回答
  •  不知归路
    2020-12-05 05:53

    #!/bin/bash  
    # functiontest.sh a sample to call the function in the shell script  
    
    choice="true"  
    function process_install  
    {  
      commands...
    }  
    
    function process_exit  
    {
      commands...  
    }  
    
    function main  
    {  
      if [[ "$choice" == "true" ]]; then  
          process_install
      elif [[ "$choice" == "false" ]]; then  
          process_exit  
      fi  
    }  
    
    main "$@"  
    

    it will start from the main function

提交回复
热议问题