GNU Info

Info Node: (autoconf.info)Testing Values and Files

(autoconf.info)Testing Values and Files


Next: Multiple Cases Prev: Portable Shell Up: Writing Tests
Enter node , (file) or (file)node

Testing Values and Files
========================

   `configure' scripts need to test properties of many files and
strings.  Here are some portability problems to watch out for when doing
those tests.

   The `test' program is the way to perform many file and string tests.
It is often invoked by the alternate name `[', but using that name in
Autoconf code is asking for trouble since it is an `m4' quote character.

   If you need to make multiple checks using `test', combine them with
the shell operators `&&' and `||' instead of using the `test' operators
`-a' and `-o'.  On System V, the precedence of `-a' and `-o' is wrong
relative to the unary operators; consequently, POSIX does not specify
them, so using them is nonportable.  If you combine `&&' and `||' in
the same statement, keep in mind that they have equal precedence.

   To enable `configure' scripts to support cross-compilation, they
shouldn't do anything that tests features of the host system instead of
the target system.  But occasionally you may find it necessary to check
whether some arbitrary file exists.  To do so, use `test -f' or `test
-r'.  Do not use `test -x', because 4.3BSD does not have it.

   Another nonportable shell programming construction is
     VAR=${VAR:-VALUE}

The intent is to set VAR to VALUE only if it is not already set, but if
VAR has any value, even the empty string, to leave it alone.  Old BSD
shells, including the Ultrix `sh', don't accept the colon, and complain
and die.  A portable equivalent is
     : ${VAR=VALUE}


automatically generated by info2www version 1.2.2.9