What is the difference:
if IsServerStarted ; then ...
and
if [ IsServerStarted -eq 0 ] ; then ...
Seems to me that these two statements should be equivalent? Strangely the second statement is always true.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The following runs the shell function or executable in
$PATHnamedIsServerStarted, and if its exit code is0(i.e. true), runs thethenbranch. If such a function or executable does not exist, the exit code will be non-0(i.e. false) and thethenbranch will be skipped.The following has
[(akatest) check whetherIsServerStartedis an integer equal to0, which (IsServerStartednot even containing a single digit) is always false. Thus,[exits with a non-0(i.e. false) code and thethenbranch is always skipped.