[Top][All Lists]

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

collecting arguments for esyscmd while sending the output to stdin

From: daniel daniel
Subject: collecting arguments for esyscmd while sending the output to stdin
Date: Sat, 17 Jul 2010 14:08:19 -0700

Say you have a `function' named _streamRevert
that takes two arguments. The first argument is
the number of the stream to collect, the second
argument is the number of the stream to which
to dump the collected stream.
To accomplish this, you make use of four auxiliary
functions: SAVE, push_divert, pop_divert, and
_streamDump. Their definitions are as follows:

define(`_streamDump',``esyscmd'(`echo 'undivert($1)` > /dev/fd/0')')

The definition of _streamRevert is here:


And you can call it to SAVE the output in diversion 2
into diversion 3, e.g.,:


but _streamRevert() outputs:
after the arguments are collected. m4 then strips the quotes
around this output and does not evaluate the _expression_.
This is not a problem. To get around this quality of quotes,
an _echo function can be written to re-send the output of
a function (i.e., re-send the output of _streamRevert and
rescan it) to stdin:

pushdef(`_echo',`esyscmd($1 > /dev/fd/0)')

This works. It is used like so:


So here is the issue. The operation of these functions works
perfectly until esyscmd is called from _streamDump.
esyscmd sees
``esyscmd'(`echo 'undivert(2)` > /dev/fd/0')'
and then expands undivert(2), but SAVE only sees
`'push_divert(3)esyscmd(echo  > /dev/fd/0)`'pop_divert()dnl

How do you get esyscmd to collect the result of the expansion
of undivert($1) as an argument to esyscmd?
Right now it seems like esyscmd expands undivert($1) but
does not capture the result of the expansion as an argument.

Note: to SAVE something in a stream, use SAVE(value,target).
SAVE(`Lorem ipsum dolor sit amet',2)

Which pushes the value into divert(2)

reply via email to

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