[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


From: Paul Eggert
Subject: Re: AS_EXECUTABLE_P again
Date: Fri, 21 Jan 2005 11:39:29 -0800
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Stepan Kasal <address@hidden> writes:

> The item about `!' mentions the following code:
>       if @var{command}; then (exit 1); else :; fi
> Can I change the suggestion to
>       if @var{command}; then false; else :; fi
> Yes, the exit code might be 255, but it shouldn't matter.

The context is a general rewrite (the preceding text is "More
generally, one can always rewrite @samp{! @var{command}} as:") so we
should give a rewrite that works in the general case.  Since "!"
always returns exit status 0 or 1, the rewrite should too.  So we
can't use "false" in the rewrite.

I installed this hopefully-simpler patch for the "test !" problem:

2005-01-21  Paul Eggert  <address@hidden>

        * doc/autoconf.texi (Limitations of Builtins): Clarify that
        "if test -d foo; ..." is portable.  Suggested by Stepan Kasal.

--- autoconf.texi       21 Jan 2005 00:03:40 -0000      1.865
+++ autoconf.texi       21 Jan 2005 19:31:51 -0000      1.866
@@ -11082,8 +11082,9 @@ operators; consequently, Posix does not 
 is nonportable.  If you combine @samp{&&} and @samp{||} in the same
 statement, keep in mind that they have equal precedence.
-You may use @samp{!} with @command{test}, but not with @command{if}:
address@hidden ! -r foo || exit 1}.
+It is safe to use @samp{!} as a @command{test} operator.  For example,
address@hidden test ! -d foo; @dots{}} is portable even though @samp{if ! test
+-d foo; @dots{}} is not.
 @item @command{test} (files)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]