You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Peter Samuelson <pe...@p12n.org> on 2005/12/10 07:05:48 UTC

[PATCH] eliminate test -a and test -o from configure bits

  [Peter Samuelson]
> > If this is going into a configure file, you shouldn't use test -a.
> > It's not POSIX, let alone classic Bourne compatible.  (Many modern
> > shells do accept it.)

[Malcolm Rowe]
> That's not the only place in configure.in or build/ac-macros that
> uses test -a.  Care to work up a patch?

Sorry, it took a couple days before I got around to it, but sure.  It's
not tested but it is a pretty simple transformation so looks safe.

Re: [PATCH] eliminate test -a and test -o from configure bits

Posted by Malcolm Rowe <ma...@farside.org.uk>.
On Mon, Dec 12, 2005 at 04:44:24PM -0600, Peter Samuelson wrote:
> [patch]

Thanks, that's great!  Committed in r17768.

Regards,
Malcolm

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] eliminate test -a and test -o from configure bits

Posted by Peter Samuelson <pe...@p12n.org>.
[Malcolm Rowe]
> Although now I come to look at it, 'test -a' and 'test -o' are
> documented as an XSI extension to POSIX.  Are there any real-life
> cases where we 'test -a' doesn't work?

I don't know.  I do know that Debian ships one very strict POSIX shell
(presumably for testing compatibility issues) which chokes on -a and
-o.  I don't know that anyone actually *uses* it as their /bin/sh -
there doesn't seem to be much point.  I use it, but only for testing
shell constructs for portability, when I'm in doubt.

From the autoconf manual, though:

    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.

It's a great reference to such issues; it also says, for example:

    Contrary to a common belief, `test -n STRING' and `test -z STRING'
    *are* portable.  Nevertheless many shells (such as Solaris 2.5, AIX
    3.2, UNICOS 10.0.0.6, Digital Unix 4 etc.) have bizarre precedence
    and may be confused if STRING looks like an operator:

        $ test -n =
        test: argument expected

> > -if test "$BINNAME" = "" -a "$APXS" = ""; then
> > +if test "$BINNAME $APXS" = " "; then
> 
> I don't like this change, though.

Fixed.  I wondered about the tradeoff of clarity / terseness myself.  I
tend to think terse things are more clear than verbose things, all else
being equal, and I have an unfortunate tendency to err on that side.

Thanks,
Peter

Re: [PATCH] eliminate test -a and test -o from configure bits

Posted by Malcolm Rowe <ma...@farside.org.uk>.
On Sat, Dec 10, 2005 at 01:05:48AM -0600, Peter Samuelson wrote:
> > That's not the only place in configure.in or build/ac-macros that
> > uses test -a.  Care to work up a patch?
> 
> Sorry, it took a couple days before I got around to it, but sure.  It's
> not tested but it is a pretty simple transformation so looks safe.

> [[[
> Eliminate use of 'test -a' and 'test -o' from configure bits.
> While commonly supported, they're not POSIX-compliant, let alone
> compatible with arbitrary pre-POSIX environments.
> No functional changes.

That looks great, thanks.  Although now I come to look at it, 'test -a'
and 'test -o' are documented as an XSI extension to POSIX.  Are there any
real-life cases where we 'test -a' doesn't work? (not that we probably
shouldn't do this anyway - I just wonder if we're fixing anything concrete
by doing so).

> Index: build/ac-macros/svn-apache.m4
> ===================================================================
> --- build/ac-macros/svn-apache.m4	(revisione 17717)
> +++ build/ac-macros/svn-apache.m4	(copia locale)
> @@ -74,7 +74,7 @@
>      APXS_EXPLICIT=1
>  ])
>  
> -if test "$BINNAME" = "" -a "$APXS" = ""; then
> +if test "$BINNAME $APXS" = " "; then

I don't like this change, though.  I know that what you've got is
functionally equivalent, but I think it obscures the purpose of the test.
Can we not use something like 'test -z $BINNAME && test -z $APXS' here?

If you could post a new patch that takes care of that, I'll lightly test
it locally (though as you say, it should be pretty safe), and commit
it for you.  You might want to wait a day to see if anyone else has any
more comments.

Regards,
Malcolm

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org