autoconf-patches
[Top][All Lists]
Advanced

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

Re: AC_DEFINE_UNQUOTED doc update


From: Akim Demaille
Subject: Re: AC_DEFINE_UNQUOTED doc update
Date: Tue, 3 May 2005 07:19:04 +0200


Le 29 avr. 05, à 15:37, Stepan Kasal a écrit :

I just don't understand the reason against telling users to quote every
argument at least once.

Same here: that is a simple rule, and simple rules are better than
rules sparing a couple of key strokes.

You have to make it "once", not "at least once".  Overquoting is also
a popular source for problems. Yes, we should tell them this. The question
is, at which level we tell them that they need not to quote everything?
        AC_DEFINE([HAVE_LIBREADLINE], [1], ...
I think we should tell them at some stage, it can save them some typing.

I disagree.  Anyway, you're not concerned with saving typing, you're
concerned with making scripts readable and maintainable.  Saving
typings has frequently been a reason for obfuscating code rather than
improving it.


As far as the other changes are concerned, let me comment on the example on
your mail:

1) foo='bla [[blubb]]'

I'd prefer this:
        [foo='bla [blubb]']

The explanation is that you simply are not allowed to write ``naked'' shell
code in configure.ac.  Every word you write is considered for expansion
by m4.  And the quote characters are treated specially.

The other style also has the nice property that you emphasize why you
needed these quotes.  You keep things local.

2) foo='['

Yes, this cannot be done.  You have to do something like this:
m4_changequote()
foo='['
m4_changequote([,])

Citing from the m4 manual:
   There is no way in `m4' to quote a string containing an unmatched
   left quote, except using `changequote' to change the current quotes.

changequote is evil, and I worked hard to get rid of it in the
context of Autoconf.  Please, keep it as distant as possible if
you want to stay away from troubles.

Here the right answer is quadruples.

3)
| AC_DEFINE_UNQUOTED([bar], ["$foo"], [bla])
| AC_DEFINE_UNQUOTED([bar], [["$foo"]], [bla])

I don't think you are right here.  The second argument is not expanded
by m4, as foo is not a defined macro.

Just do
   AC_DEFINE_UNQUOTED(bar, "$foo", [bla])

I strongly recommend quoting every argument once.  The recent changes
that specify that it's not always useful are just making things easier
to write incorrectly.





reply via email to

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