Mike McLagan wrote,
| I was trying to use $@ because that's what the man page suggested. I had
| started using $1, but it wasn't doing what I wanted it to do. I had set up
| a simple recipe:
|
| :0
| |echo $1 >> ~/test
|
| This got me null lines.
OK, here's the deal there. When you have characters from $SHELLMETAS in
an action line (or a "?" condition) and thus procmail invokes a shell to
run it, procmail also doesn't evaluate variables for the shell: it just
passes the line. But procmail does export all *named* variables, so those
will have the values you expect.
So if you had done this:
RECIP=$1
:0hi # what, no c?
| echo $RECIP >> ~/test # I trust your $SHELL understands tildes.
It would work, because procmail would export RECIP, so the shell running the
action line would know its value. But in
| echo $1 >> ~/test
the invoked shell uses its own $1, which is probably unset. That's why
you got blank lines.
If there were no characters from $SHELLMETAS in the action line, and thus
procmail ran it, it would expand $1 just like a named variable. Personally,
I never bank on when I'll add a $SHELLMETAS character to an action line or
remove the last one from it, so if I need a special variable in an action
line, I always copy it into a regular variable first and use the regular
variable instead. That way, shell or no shell, it will have the value I
want.
For example, I have a recipe where an action line that invokes a shell needs
the PID of procmail:
PID=$$
:0 flags
* conditions
| program opts some args $PID other args ;
If I did it like this:
:0 flags
* conditions
| program opts some args $$ other args ;
then the shell running the action line would expand $$ to its own PID, not
to that of procmail, which is the one I need.
| I tried:
|
| LOG="This is the recipient '$1'"
|
| That didn't get me the desired result.
Well, maybe it would have if you hadn't put the extra level of strong quotes
around $1; they should be meaningless inside weak quotes, but procmail may
differ from sh and its derivatives on that.
| Appearantly it doesn't recognise the form:
|
| * 1 ?? <userid>@
|
| as being equivalent to the above.
No, it does not. Special variables cannot be used in that syntax. To use
something like $_ or $$ or $- or $1, you have to copy it into a regular
variable, as you've seen.