[Top][All Lists]

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

Re: Proper m4 quoting

From: Eric Blake
Subject: Re: Proper m4 quoting
Date: Thu, 14 Apr 2011 12:49:09 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.9

[please don't top-post on technical lists]

On 04/14/2011 12:39 PM, Too, Justin A. wrote:
> Hi Eric,
> Sorry, here you are:


> I've tried many permutations of quoting, but obviously I'm missing a
> fundamental understanding for this use case:
> ------------------------------------------------------------------------
> [
> AC_MSG_CHECKING([for test])
> test_executable="$$][(top_builddir)/scripts/test/bin/my_test"

Why the $$ here?  M4 doesn't give $$ any special treatment, and the m4
end-quote/start-quote sequence of ][ doesn't really matter.  You ended
up creating the following line of shell code:


and, at shell time, $$ is the process id, explaining your results.

> AC_SUBST(QMTEST, [$test_executable])

While this line works as-is (provided QMTEST is not an m4 macro name),
you are better off getting in the habit of recommended quoting style:

AC_SUBST([QMTEST], [$test_executable])

> 22839(top_builddir)/scripts/test_harness/test/bin/my_test
> I need
> $(top_builddir)/scripts/test_harness/test/bin/my_test

Then use:


to get a literal $ into the contents of $test_executable, or:


if you wanted the shell to expand $top_builddir prior to assigning to
$test_executable.  At any rate, neither line variant contains anything
that requires extra m4 quoting or escaping.

Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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