shell script to determine whether the previous command executed successfully
the shell using the symbol "$?" to display a command on the return value of success if it is 0 behalf of the Executive, the other for failure.
Combined to achieve the if-else statement to determine whether a command is executed successfully.
Scenario: If the clone success of the project, only to package work
Sample script:
echo "clone命令"
git clone -b <branchName> <gitAddress>
if [$? -ne 0]; then
echo "faild"
else
echo "success"
fi
running result:
Reference documents: