[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: passing positional arguments to esyscmd
From: |
Gary V. Vaughan |
Subject: |
Re: passing positional arguments to esyscmd |
Date: |
Wed, 05 Oct 2005 17:26:26 +0100 |
User-agent: |
Mozilla Thunderbird 1.0 (X11/20050305) |
Sergey Astanin wrote:
Hello, everybody,
I cannot figure out how to pass positional arguments of a macro to
esyscmd. I tried googling but found no examples beyond simple calls like
esyscmd(`date'). In my case the shell command depends on positional
arguments: I want to write macro like _MY_MACRO(var1,var2) that expands to
``var1 : some-text-generated-using-var2'', where
``some-text-generated-using-var2'' is an output of my perl script
``./script.pl var2''.
The first thing I tried was:
m4_define(`_MY_MACRO', `$1 : 'm4_esyscmd(`./script.pl '$2))
here you are running m4_esyscmd(`./script.pl '`'), before adding it's
output to the definition of _MY_MACRO. I assume you want to have
_MY_MACRO invocations incorporate an expansion of esyscmd() at each
call?
It does not work, and the scipt diagnostics shows that it was called
without any argument. I also tried m4_esyscmd(`./script.pl $2'),
m4_esyscmd(./script.pl $2), but none of them worked.
Though, if I write something like
m4_define(`_MY_MACRO', `$1 : '(`./script.pl '$2))
the shell command is displayed correctly: ``./script.pl var2''.
So, I suppose, esyscmd expands its arguments in a different way, than that
of a normal macros, or probably, the positional parameters are treated
differently. The question is how I may call esyscmd and have all its
arguments expanded.
Nope. Positional parameters are expanded in the body of a macro before
anything in it is pushed back on the input stack.
I would appreciate any clue or advise, or a workaround.
$ m4
define(`_MY_MACRO', `$1: esyscmd(`echo $2')')dnl
_MY_MACRO(arg1, arg2)
arg1: arg2
Works for me.
HTH,
Gary.
--
Gary V. Vaughan ())_. address@hidden,gnu.org}
Research Scientist ( '/ http://tkd.kicks-ass.net
GNU Hacker / )= http://www.gnu.org/software/libtool
Technical Author `(_~)_ http://sources.redhat.com/autobook
signature.asc
Description: OpenPGP digital signature