procmail
[Top] [All Lists]

Re: stripping MATCH's right hand side

2001-12-08 11:16:51
On Fri, Dec 07, 2001 at 02:40:15PM -0600, David W. Tamkin wrote:

That's fine, no problem, but since I like ksh (well, pdksh) for $SHELL I'd
rather use just the shell than a shell plus sed:

 :0
 * ^List-Unsubscribe:.*leave-isp-\/(_dot_)*(_at_)(_dot_)*isp-lists(_dot_)com
 isp-`ksh -c 'echo ${MATCH%%-*}'`

Isn't that an even larger footprint?  If you run ksh inside a backquote,
you're running ksh inside your shell.  You'd probably want that action
to be merely:

        isp-`echo "${MATCH%%-*}"`

Heck, couldn't we even make sed the shell?

        oldSHELL="$SHELL"
        SHELL="/usr/bin/sed -e 's/-[^-][^-]*(_at_)(_dot_)*$//'"
        :0
        * 
^List-Unsubscribe:.*leave-isp-\/(_dot_)*(_at_)(_dot_)*isp-lists(_dot_)com
        isp-`"$MATCH"`
        SHELL="$oldSHELL"

This of course doesn't work because the shell must be a whole binary,
rather than a command line that would be interepreted by a shell.  This
kind of solution seems simultaneously elegant and grotty.  Can it be
made to work?  Could we make SHELL=/usr/bin/sed and have the backquoted
text contain everything needed to make the substitution?

-- 
  Paul Chvostek                                             
<paul(_at_)it(_dot_)ca>
  Operations / Development / Abuse / Whatever       vox: +1 416 598-0000
  IT Canada                                            http://www.it.ca/

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail