I had suggested to Gino Filicetti:
| > Why are you calling cut? To get rid of the initial space? Just use
| > formail's -z option:
| >
| > FROM_ADDRESS=`formail -rzxTo:`
| >
| > That saves calling cut *and* calling a shell to handle the piping from
| > formail to cut. Better yet, reduce the feed to formail to only the head:
| > :0h
| > FROM_ADDRESS=| formail -rzxTo:
Gino replied,
| Ok, so if I use the pipe as you suggested I'd save invoking a shell? but
| doesn't a shell need to be invoked to run formail anyways?
No; if there are no characters from $SHELLMETAS in the command (the initial
pipe symbol doesn't count), procmail runs the program itself.
| Also, I don't think my formail has a -z option (unless it's undocumented)
| I have an unknown version of formail and it doesn't have a man page, but
| typing formail -h brings up a list of options and -z isn't there....
You can still get around it:
:0h
SENTFROM=| formail -rxTo:
:0
* SENTFROM ?? ^^ *\/[^ ].*
{ FROM_ADDRESS=$MATCH }
Note that if $SENTFROM doesn't begin with a space, the recipes still work,
just as long as there is at least one non-space somewhere in $SENTFROM.
| > :0 # twenty-five dots
| > * NAME ?? ^^\/..........................
| > { NAME=$MATCH }
| I don't like the idea of using the dots.... what if the variable is less
| than 25 what happens??? and if it's null??
If $NAME is null, unset, or shorter than twenty-five characters, then the
condition doesn't match, so the code in the braces is skipped, and $NAME is
left at its previous value, exactly as you want.
| ... how much difference does it make taking out all this redundant stuff?
Enough in processing time and size of your rcfile to be worth the trouble, I
should think.
| > I still question whether you don't want to truncate to twenty-five
| > characters *after* filling in $FROM_ADDRESS if $NAME was empty. What if
| > $FROM_ADDRESS is too long?
|
| No no... the addresss has to stay intact or else how could I put it on my
| mailing list?? no, address can be as long as possible, EVEN when it's
| subbed into $NAME....
OK, Gino, thanks for explaining. I'd asked before but you didn't answer
then. I don't know how you're using these variables, so it wasn't clear to
me that $NAME shouldn't be truncated if you fill it in from $FROM_ADDRESS.