nmh-workers
[Top] [All Lists]

Re: [Nmh-workers] problem with mark zeroing out sequences

2014-02-25 21:53:42
I suppose I could try, but I've not used a C debugger

Hmm, on a hunch I just discovered that somehow the call to mhstore
in mime-add-hook's for loop is the trigger... of course that's the
raison d'etre of the script :-/

Hopefully it's not too hard to follow:

#!/bin/sh
VERSION=0.05

#Diagnostic messages
DEBUG=0

#Backup message suffix
BAK=`mhparam mimehook-bak`

SLOCAL=`mhparam mimehook-slocal`

[ $DEBUG = 1 ] && echo -n "Processing message $1";

if grep -q -E '^MIME' $1 ; then
    [ $DEBUG = 1 ] && echo " ...is MIME"

    SRCDIR=`dirname $1`
    MSG=`basename $1`

    #Don't clobber main context
    if [ -n $SLOCAL ]; then
        export MHCONTEXT=`$SLOCAL`
        [ $DEBUG = 1 ] && echo "slocal context $MHCONTEXT"
        folder -fast +$SRCDIR >/dev/null
    fi


    for PART in `mhstore $MSG 2>&1 | awk 'match($0,/as file .+/){print 
substr($0,RSTART+8,RLENGTH)}'`; do
        [ $DEBUG = 1 ] && echo "Processing part $PART";

        #Tweak -auto name to match message number
        PARTDIR=`dirname $PART`
        PARTFILE=`basename $PART`
        if `echo $PARTFILE | awk "/^$MSG\./ { exit 1 }"` ; then
            NEWPART="$PARTDIR/$MSG.$PARTFILE"
            [ $DEBUG = 1 ] && echo "Renaming -auto part $PART to $NEWPART";
            mv $PART $NEWPART
            PART=$NEWPART
        fi

        mv -i $PART $SRCDIR
    done


    #DEFANG plain text
    if [ ! -e "$1.$BAK" ]; then
        [ $DEBUG = 1 ] && echo "Defanging MIME with mhfixmsg: backup in 
$1.$BAK";
        cp -i $1 $1.$BAK
        mhfixmsg $1
    fi

    #Remark as unread
    UNSEEN=`mhparam Unseen-Sequence`
    if [ -n $UNSEEN ]; then
        mark $MSG -nozero -add -seq $UNSEEN
    fi
else
    [ $DEBUG = 1 ] && echo " ...is NOT MIME"
fi

_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers

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