Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I really can't understand why if I do integer comparision like this:
$ [ 1 == 1]
It should be:
Code:
[ 1 == 1 ]
Quote:
Originally Posted by marcoubuntu
or
$ [ 1 -eq 1 ]
then
echo $?
I get 0 that is false instead of 1 that is true!
What I'm missing?
See what man bash says:
Code:
EXIT STATUS
The exit status of an executed command is the value returned by the
waitpid system call or equivalent function. Exit statuses fall
between 0 and 255, though, as explained below, the shell may
use values above 125 spe- cially. Exit statuses from shell
builtins and compound commands are also limited to this
range. Under certain circumstances, the shell will use special
values to indicate specific failure modes.
For the shell's purposes, a command which exits with a zero exit
status has succeeded. An exit status of zero indicates success. A
non-zero exit status indicates failure. When a command terminates on
a fatal signal N, bash uses the value of 128+N as the exit status.
Last edited by average_user; 04-09-2018 at 02:40 PM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.