nmh-workers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nmh-workers] message rewrite/fix up


From: David Levine
Subject: Re: [Nmh-workers] message rewrite/fix up
Date: Sun, 10 Feb 2013 11:58:36 -0500

Ralph wrote:

> Why not replace all three with rmmproc;  I've already got that doing
> what *I* want.  It's a pain it's not used everywhere as it is without
> adding more exceptions.

Good idea.

I'll add a sample rmmproc.messageid script for those who want
something to start from, how does the one below look?

David


#! /bin/sh
##
 # rmmproc.messageid -- backs up message/file to file based on Message ID
 #
 # This code is Copyright (c) 2013, by the authors of nmh.
 # See the COPYRIGHT file in the root directory of the nmh
 # distribution for complete copyright information.
 #
 # If called on a message, the current directory is the message folder
 # and $1 is the message filename.
 # If called on a file, $1 is the full path to the file.
 #
 # The backup directory will be:
 #   1) If input is a message, the folder of the message.
 #   2) If input is a file, the directory of the file.
 #   3) If input is standard input (-), the user's MHPATH directory.
 #
 # The backup filename will be:
 #   1) Message-ID with all / and \ converted to periods.  Message-IDs
 #      should not contain \, but some filesystems can't handle them.
 #      Message-IDs should be unique, so there should be no need to
 #      backup a file with the same name, especially if it is
 #      malicious.  If the backup file already exists, use 2).
 #   2) Concatenation of BACKUP_PREFIX and input filename.
 #
 # If unable to backup the message, exit with status 1.
##

if [ "$1" = - ]; then
    #### Input is stdin, put backup in user's MHPATh directory.
    dir=`mhparam path`
    #### If Path is relative, prepend home directory.
    [ `dirname "$dir"` = . ]  &&  dir="$HOME/$dir"
else
    dir=`dirname "$1"`
fi

messageid=`grep -i ^Message-Id "$1" | \
    sed -e 's/^[Mm][Ee][Ss][Ss][Aa][Gg][Ee]-[Ii][Dd]: *<*//' -e 's/>$//' | \
    tr '[/\\]' '[..]'`

if [ "$messageid"  -a  ! -f "$dir/$messageid" ]; then
    filename="$dir/$messageid"
else
    filename="$dir"/`mhparam sbackup``basename $1`
fi

mv "$1" "$filename"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]