What does " test ... || gcc ..." mean?

Andrea 'Fyre Wyzard' Bocci fwyzard@inwind.it
Fri Dec 7 04:44:00 GMT 2001


At 16.57 06/12/01 (GMT +0100), Luker Lu wrote:
>Hi all,
>
>I want to understand the source code of gcc so I am studying the build
>process at first. In the process of "make bootstrap", the following command
>appears:
>
>test x"no" != xyes || \
>   gcc -c -DHAVE_CONFIG_H -g -O2 -I. -I../../source/libiberty/../include
>../../source/libiberty/argv.c -o pic/argv.o
>
>I know what "test" and "gcc" are, but can't understand the whole command.
>Could someone explain me what it does? What does this "||" between test and
>gcc mean?
>thanks in advance!
>
>Luker Lu

Here is a fast explanation:

|| is the OR operator. It can also be used as a flow control operator, just 
like an if-then-else check.
That is, you can write a C style if-then-else block
if (condition)
   true-statement
else
   false-statement

as
test condition && true-statement || false-statement

However, unlike the C block, the "&& true-statement part" is not necessary, 
and can be skipped.

For more infos, have a look at sh or bahs man pages.

fwyzard




More information about the Gcc-help mailing list