procmail
[Top] [All Lists]

Re: $@ is driving me crazy

1999-03-23 00:34:05
"John D. Hardin" <jhardin(_at_)wolfenet(_dot_)com> writes:
On Mon, 22 Mar 1999, Philip Guenther wrote:

"John D. Hardin" <jhardin(_at_)wolfenet(_dot_)com> writes:
...
LOG="\$(_at_)="
:0 ciw
| echo '{' $@ '}' >> $LOGFILE 2>&1
...

I could have sworn this limitation was documented somewhere in the
manpages, but I can't find it now:

     $@ only expands to procmail's arguments when procmail is
     doing the expanding.  If any characters from $SHELLMETAS
     occur in the command then the expansion is left to the
     shell which does not have that information availible to it.

That would explain it. The example given in Jari's tips page (sec. 
20.38) does work. 

Is there any good reason why procmail only expands $@ in command
lines? This combination of restrictions has been making me crazy for
half a day now...

It's because procmail doesn't actually interpolate the values into the
command line it's building, but rather just makes note of the position
in the command-line-to-be and jiggles them into the argv vector of the
exec call directly.  The really sweet side effect of this is that
there's no limit on the size or number of arguments passed through
procmail via this except the one imposed by the kernel.

It's also arguable that expanding $@ into a single string is the Wrong
Thing 99% of the time.  You should either be passing it through as a
string of arguments to another command or iterating via a recursive
rcfile.  Anything else will lose the argument boundaries.


Philip Guenther

<Prev in Thread] Current Thread [Next in Thread>