pipe into command can't take arguments
Brought to you by:
efalk
sortmail's rc file used to allow you to feed the mail
to a command with specified arguments. The current
sortmail requires there to be no arguments provided to the
given command, which cripples the usefulnesss of the
pipe command.
E.g. my .sortmailrc file used to have lines like this:
/^Subject: Testing 2/s:| /usr/local/script/addmail
/home/luke/Mailboxes/tmp luke 'More test mail'
/usr/local/lib/sounds/NewMail.au
Now, that just provokes the error:
sortmail 2006-7-16 1:20:42: syntax error line 7,
"/home/luke/Mailboxes/tmp luke More-test-mail
/usr/local/lib/sounds/NewMail.au" unrecognized
luke
Logged In: YES
user_id=20823
I had a quick look at the source, and believe that the check
for extraneous characters on the sortmailrc line (in expr.c
line 193) should not apply to the pipe command.
luke
Logged In: YES
user_id=167561
Thanks, I'll look into it.
Logged In: YES
user_id=20823
I had a little play with it tonight, and I think this does
the trick. Please see what you think.
diff expr.c expr.c.orig
1007,1014c1007
< if (ptr[-1] == '|')
< {
< /* The whole rest of the line is the command */
< has_variables = strchr(ptr, '$') != NULL;
< i = strlen(ptr);
< len += i ; ptr += i ;
< }
< else if( strchr("eEmf+da|", ptr[-1]) != NULL )
---
> if( strchr("eEmf+da|", ptr[-1]) != NULL )
It seems to work fine.
However, during testing I discovered that the treatment of
subject line pattern matching is different from the ancient
version fo sortmail which I'd been using. It used to work
if I had
/^Subject: something/s:<etc....>
But the new sortmail strips off the "Subject: " from the
subject line, so such patterns have to be replaced by:
/^something/s:<etc...>
Not a major drama, just a small gotcha for me.