Timothy Luoma asked,
| Perhaps I'm just too sleepy to figure this out, but how can I do this:
| if [ "$VAR1" = "" ]
| then
| OTHERVAR=x
| else
| OTHERVAR=y
| fi
Now, here's the question, Timothy: your subject line speaks of a variable's
not being set, but the sample sh code you gave treats a null (but set) vari-
able the same as an unset one.
To emulate in procmailrc language what you have written there,
:0
* VAR1 ?? ^^^^
{ OTHERVAR=x }
:0E
{ OTHERVAR=y }
or equivalently,
:0
* $ ${VAR1:+!}
{ OTHERVAR=x }
:0E
{ OTHERVAR=y }
but if you really want to assign OTHERVAR=x only if VAR1 is unset (and y
if VAR1 is set, even if VAR1 is null), you need to do this [note the absence
of a colon in the condition]:
:0
* $ ${VAR1+!}
{ OTHERVAR=x }
:0E
{ OTHERVAR=y }
| So I put the real LASTFOLDER into another variable called REALFOLDER and
| want to use
|
| TRAP='\
| echo "\
| _________ NEW $TYPE MESSAGE FROM: $FROM
| To/Cc $TO / $CC
| Subject $SUBJECT
| Date $DATE
| Size $SIZE
| ID $ID
| _________ MESSAGE WENT TO: $LASTFOLDER
| "'
|
| to log.... However, if "REALFOLDER" has a value, then I want to use the
| value of REALFOLDER for LASTFOLDER in the TRAP statement.
Just change $LASTFOLDER to ${REALFOLDER-$LASTFOLDER} in your trap:
TRAP='\
echo "\
_________ NEW $TYPE MESSAGE FROM: $FROM
To/Cc $TO / $CC
Subject $SUBJECT
Date $DATE
Size $SIZE
ID $ID
_________ MESSAGE WENT TO: ${REALFOLDER-$LASTFOLDER}
"'