The above is the original code book, my problem is yes_or_no "" this sentence is a function call, I entered the yes, the execution of a program is return 0;; that is returned by the function is 0, then the if yes_or_no "" is not equivalent to if 0, select statement at should be to the statement following the else, echo "Never mind" this sentence, why the actual implementation of the echo "Hi , nice name" in this sentence.?

Confused for a long time, seeking to explain

Started by Robin at February 01, 2016 - 8:15 AM

if/Then structure is used to determine the list of commands exit status code is 0 (as in UNIX convention, 0 indicates "success"), if successful, then one or more commands the next.

Posted by Angus at February 03, 2016 - 8:51 AM

Under Linux, each execution will return an exit code to the caller, general 0 on success, other values indicate a problem, of course, some an exit code has special meaning.

Posted by Lucinda at February 12, 2016 - 8:54 AM

Well, positive solutions upstairs, general UNIX systems are like this, you use the echo $? Look at last execution status code, as long as it is successfully executed, it returns 0, 0 Non failed.

Posted by Kelly at November 18, 2016 - 2:58 AM

0 said that the successful execution, non 0 execution failed. Here and 1 and 0 in the binary representation of meaning apart.

Posted by Carr at November 26, 2016 - 3:44 AM

if yes_or_no "$1"That is the function if yes_or_no, the return value of parameter

Posted by Eugene at December 07, 2016 - 4:38 AM

As you said, the 0 represents success, I wrote the following code:
if 0
then
echo 0
else
echo 1
fi
The implementation result is output by 1, so 0 and return status here 0 different?

Posted by Robin at December 11, 2016 - 4:52 AM

I understand what you say, you see my problem.?
If behind the function that returns 0
Why is the implementation of then code behind the?
And I wrote a if 0, he performed really behind the else code.

Posted by Robin at December 13, 2016 - 5:07 AM

You mean the return value is not equal to the number of 0 0?
if yes_or_no "$1"
This is a function that returns 0, not 0 as you and if?

Posted by Robin at December 21, 2016 - 5:11 AM

The same return 0 procedure is completed, the normal exit, 0 passed to the if judge if if true 0 is then executed branch conditions inside the then sentence

Posted by Lucinda at January 01, 2017 - 5:48 AM

Yes, not the same.

if/Then structure is used to determine the list of commands exit status code
Please note, is a list of commands.

That is to say
if 0
Shell will use 0 as a command to execute this command, it is obvious that there is no 0, then the exit status code is not 0, so the output of 1.

In the output before the 1 should have a command not found.?

Posted by Angus at January 08, 2017 - 7:29 AM

You have a look at this,. It is understood, the 0 is true, not 0 as false.