Exit a Script On Error

后端 未结 5 738
温柔的废话
温柔的废话 2021-01-30 04:53

I\'m building a Shell Script that has a if function like this one:

if jarsigner -verbose -keystore $keyst -keystore $pass $jar_file $kalias
then
            


        
5条回答
  •  抹茶落季
    2021-01-30 05:20

    Are you looking for exit?

    This is the best bash guide around. http://tldp.org/LDP/abs/html/

    In context:

    if jarsigner -verbose -keystore $keyst -keystore $pass $jar_file $kalias
    then
        echo $jar_file signed sucessfully
    else
        echo ERROR: Failed to sign $jar_file. Please recheck the variables 1>&2
        exit 1 # terminate and indicate error
    fi
    
    ...
    

提交回复
热议问题