procmail
[Top] [All Lists]

Re: Putting some text into the Subject

1997-06-15 19:18:00
Era Eriksson suggested to Timothy Luoma,

|     # Now, FIRST contains everything up to the line break, 
|     # and LAST, everything after it (if anything)
| 
|     NEWSUBJ="$FIRST${LAST:+
|       }$LAST"
| 
| The funny ${...} expression adds a newline and a tab if LAST is
| defined, and nothing otherwise. (Is this implemented in Procmail
| itself or does it depend on whether your shell implements it? I think
| I've seen some /bin/sh which didn't understand this construct.)

${var-text}, ${var:-text}, ${var+text}, and ${var:+text} are implemented
within procmail, and procmail will handle them in Era's example.

However, if a pipe or filter or capture action line or a backquote assignment
contains those expressions and also contains any character from $SHELLMETAS,
$SHELL will try to evaluate them, and then they will be shell-dependent.
If that is a problem, you can change this:

   :0 flags
   * conditions
   | stuff with ${var+/-text} and a shellmeta

to this:

   variable_as_adjusted=${var+/-text}
   :0 flags
   * conditions
   | stuff with $variable_as_adjusted and a shellmeta