[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Proper m4 quoting
From: |
Too, Justin A. |
Subject: |
Re: Proper m4 quoting |
Date: |
Thu, 14 Apr 2011 12:04:56 -0700 |
User-agent: |
Microsoft-MacOutlook/14.2.0.101115 |
On 4/14/11 11:49 AM, "Eric Blake" <address@hidden> wrote:
>[please don't top-post on technical lists]
I have much to learn =)
>
>On 04/14/2011 12:39 PM, Too, Justin A. wrote:
>> Hi Eric,
>>
>> Sorry, here you are:
>
>Thanks.
>
>>
>> I've tried many permutations of quoting, but obviously I'm missing a
>> fundamental understanding for this use case:
>>
>> ------------------------------------------------------------------------
>>
>> AC_DEFUN([SUPPORT_TEST],
>> [
>> 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:
>
>test_executable="$$(top_builddir)/scripts/test/bin/my_test"
>
>and, at shell time, $$ is the process id, explaining your results.
I think in my rush, I was confusing Automake/m4 issues, hence the '$$',
since I was trying to keep the '$'.
>
>> 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:
>
>test_executable="\$(top_builddir)/scripts/test/bin/my_test"
>
>to get a literal $ into the contents of $test_executable, or:
>
>test_executable="$top_builddir/scripts/test/bin/my_test"
>
>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 http://libvirt.org
>
Thank you for your help, everything is good to go now.
Justin
>