I'm a beginner in bash scripting, so some features aren't clear for me, for example this one below.
man bash
says:
if list; then list; [ elif list; then list; ] ... [ else list; ] fi
The if list is executed. If its exit status is zero, the then list is executed.
Otherwise, each elif list is executed ...
Key information for me is that exit status in if list
should be 0
.
I execute a command in terminal:
if [[ /usr/bin/false && 0 ]] ; then echo success ; fi
if list
here is /usr/bin/false && 0
and I expect, that this command will print nothing because of /usr/bin/false
, which exit status is always 1
. But it prints success, as if the exit status of the /usr/bin/false && 0
command was 0!
I've checked /usr/bin/false && 0
exit status separately:
$ /usr/bin/false && 0
$ echo $?
1
Status is 1
, as I expected. But I don't get why if
statement above executes as if it was 0
.