procmail
[Top] [All Lists]

Re: Exit an included rc file?

1997-04-14 13:17:00
Lars Kellogg-Stedman asked,

| Is there an easy way to exit from an rc file included via the INCLUDERC
| variable?  I was hoping that setting the HOST variable would work, but
| that exits from *everything*.

Ah, so you mean "return from" rather than "exit from".  OK ...

| What I want is to immediately exit at the top of an rc file if a given
| header exists.  Something like:
| 
| :0
| * $ ^$THE_HEADER_I_WANT
| { HOST=_exit_from_rc_file_ }

| Any thoughts?

Yes, here's one: if you want to return "immediately" right "at the top,"
don't enter in the first place.  Back in the rcfile from which you called
this one, don't say

  INCLUDERC=the_rcfile_under_discussion

but rather

  :0
  * $ ! ^$THE_HEADER_LARS_SPECIFIES
  { INCLUDERC=the_rcfile_under_discussion }

But as long as we're so close to the subject, let's get to the more difficult
question of wanting to return from the middle of an included rcfile.

| I suppose one alternative is to wrap the entire rc file inside the
| nesting block; that is:
| 
| :0
| * $ ! ^$THE_HEADER_I_WANT
| {
|      ...the other recipes...
| }

That would be the usual way.

| The difficulty here is that these recipes are being auto-generated from
| *other* rc scripts, and trying to wrap them inside something like this
| adds an additional level of complexity (and the resulting file offends
| my aesthetics :-).

Perhaps this suggestion, though it still adds an additional level of
complexity, is less offensive esthetically:

  :0
  * $ ! ^$THE_HEADER_LARS_SPECIFIES
  { INCLUDERC=some_third_rcfile }

and there the second rcfile ends.  Then the automatically generated recipes
can be appended to the third rcfile instead of being inserted between
existing braces in the second one.  The drawbacks are (1) it sucketh up an
inode; (2) it sucketh up the minimum disk use for a file; (3) it keepeth an
additional file descriptor open during inclusion of the third rcfile when
the header is present.

Some day Stephen plans (maybe he has changed his mind, though) to implement
procmailrc functions; then there will be a way to return from the middle.
But if you want to return at the top, just don't enter in the first place.

<Prev in Thread] Current Thread [Next in Thread>