autoconf-patches
[Top][All Lists]
Advanced

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

Re: Why doesn't this quote properly?


From: Stepan Kasal
Subject: Re: Why doesn't this quote properly?
Date: Tue, 23 Nov 2004 12:58:27 +0100
User-agent: Mutt/1.4.1i

Hello,

On Tue, Nov 23, 2004 at 12:58:20AM -0800, Paul Eggert wrote:
> Alexandre Duret-Lutz <address@hidden> writes:
> > This chunk looks erroneous to me: the help string mentions $2 but the
> > code no longer uses it.

Thank you, Alexande for catching this bug.  It was present in the original
example and I haven't noticed it.

Regarding to Paul's patch:

> --- autoconf.texi     22 Nov 2004 23:31:56 -0000      1.840
> +++ autoconf.texi     23 Nov 2004 09:01:01 -0000      1.841
> @@ -13077,7 +13077,10 @@ AC_DEFUN([MY_ARG_WITH],
>    [AC_ARG_WITH([$1],
>       [AS_HELP_STRING([--with-$1], [use $1 (default is $2)])],
>       [ac_cv_use_$1=$withval],
> -     [ac_cv_use_$1=no])])
> +     [ac_cv_use_$1=no])
> +   AC_CACHE_CHECK([whether to use $1],
> +     [ac_cv_use_$1],
> +     [ac_cv_use_$1=$2])])

I beleive this doesn't fix it---it still sets ac_cv_use_$1=no before
AC_CACHE_CHECK comes in.

I suggest the following change instead:
> -     [ac_cv_use_$1=no])])
> +     [ac_cv_use_$1=$2])])

(Please note that my patch has also removed AC_CACHE_CHECK from the
previous example.)

I have several more comments:

1) The first example now looks like this:

AC_ARG_WITH(foo,
  [AS_HELP_STRING(--with-foo,
     [use foo (default is no)])],
  [ac_cv_use_foo=$withval],
  [ac_cv_use_foo=no])

The 3rd and 4th parameters are literal shell code.  Thus, according the
rules which the manual preaches, they should be double quoted.
Or, if we say that the shell code is ``simple enough'', they need not be
quoted at all.  (This is what I proposed in my original patch.)

I think it's not good to have the arguments single quoted.

2) Considering the MY_ARG_WITH example.
Someone might try to use it this way:

AC_DEFUN([MY_FOO], [foo])
AC_DEFUN([MY_NO], [no])
MY_ARG_WITH([MY_FOO], [MY_NO])

To get this right, you have to modify the definition, for example like this:

AC_DEFUN([MY_ARG_WITH],
  [AC_ARG_WITH([$1],
     [AS_HELP_STRING([--with-$1], [use $1 (default is $2)])],
     [[ac_cv_use_]$1[=$withval]],
     [[ac_cv_use_]$1=$2])])

3) A related problem appears when you really try the code from 2).
The configure script contains the following comment:
# Check whether --with-MY_FOO or --without-MY_FOO was given.
This can be fixed by a slight modification to the definition of
AC_ARG_WITH.

All of the things mentioned in this mail are implemented in the patch attached
to this mail.  (Applies to current CVS.)

Have a nice day,
        Stepan

Attachment: autoconf-20041123-ac_arg_with.patch
Description: Text document


reply via email to

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