autoconf-patches
[Top][All Lists]
Advanced

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

Re: OpenBSD shell, errexit, and && in if clause


From: Ralf Wildenhues
Subject: Re: OpenBSD shell, errexit, and && in if clause
Date: Tue, 2 May 2006 02:26:24 +0200
User-agent: Mutt/1.5.11+cvs20060403

Hi Paul,

* Paul Eggert wrote on Mon, May 01, 2006 at 07:37:55PM CEST:
> Ralf Wildenhues <address@hidden> writes:
> 
> > +The address@hidden 4.8 shell
> 
> Thanks, but the latest OpenBSD release is 3.9, so there's something
> wrong here.  Perhaps you meant "3.8"?

Yes, sorry about that.  OpenBSD 3.8 is what I tested on.  The followup
to the upstream bug report suggests that it has not been fixed yet:
http://cvs.openbsd.org/cgi-bin/query-pr-wrapper?full=yes&numbers=5093

> This reminds me of a longstanding related problem in BSD sh and make.
> I installed this patch into Autoconf, which combines the two ideas.

Thanks.  Note however: 

> +Even relatively-recent versions of the @acronym{BSD} shell (e.g.,
> address@hidden 3.4) wrongly exit with @option{-e} if a command within
> address@hidden&&} fails inside a compound statement.  For example:
> +
> address@hidden
> +#! /bin/sh
> +set -e
> +foo='nonempty'
> +test -n "$foo" && exit 1
> +echo one
> +if :; then
> +  test -n "$foo" && exit 1
> +fi
> +echo two
> address@hidden example
> +
> address@hidden
> +does not print @samp{two}.  One workaround is to use @samp{if test -n
> +"$foo"; then exit 1; fi} rather than @samp{test -n "$foo" && exit 1}.

This example isn't right, in that it does not expose the problem, as
the first command in the AND list should fail.  Did you mean "test -z"
instead of "test -n" (four instances), or "foo=''", and is there a
reason to prefer it over the simpler "false"?

Cheers,
Ralf




reply via email to

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