From: Alfie Costa (agcosta@gis.net)
Date: Thu Apr 06 2000 - 06:37:45 CEST
Tweak the third.
In /usr/bin/formail (which is a link to /usr/script/mu-formail)
The original says:
*)
if [ -z "${body}" ] && [ -z "$1" ] ; then
body=yes
echo
fi
if [ ${body} ] ; then
echo "$@"
fi
...which I changed to:
if [ ${body} ]
then echo "$@"
else
if [ -z "$1" ]
then
body=yes
echo
fi
fi ;;
...which does the same thing but saves one or even two tests, depending on what
happens. I added a ";;" at the end, as when those are missing from within a
'case...esac' it can cause trouble, though I forget how exactly. Later in the
file there's a second similar test, which also has been changed.
#! /bin/ash
#########################################
# mu-formail - rustic formail for muLinux
# by M. Andreoli (1998)
##########################################
#set -x
opt=$1
usage()
{
cat <<END
mu-formail : rustic formail (by M. Andreoli)
Usage:
cat mailbox | formail -s # split message in /tmp/msg.#
cat msg | formail -r # reply to stdout
cat msg | formail -f # format message
END
}
# Split message
split()
{
number=0
echo -n "splitting. Wait, please ..."
cat | while read line
do
set -- $line
case $1 in
>From )
new=yes
number=`expr $number + 1`
echo -n " $number" > /tmp/msg.$number ;;
*)
echo "$@" >> /tmp/msg.$number ;;
esac
done
echo " "
}
# format, removing spurious headers
format()
{
body=
cat | tr -d '\015' | while read line
do
set -- $line
case $1 in
From:)
shift
FROM="$@"
echo "From: $FROM" ;;
Subject:)
shift
SUBJECT="$@"
echo "Subject: $SUBJECT" ;;
*)
if [ ${body} ]
then echo "$@"
else
if [ -z "$1" ]
then
body=yes
echo
fi
fi ;;
esac
done
}
# reply
reply()
{
body=
cat |tr -d '\015' | while read line
do
set -- $line
case $1 in
From:)
shift
FROM="$@"
echo "To: $FROM" ;;
Subject:)
shift
SUBJECT="$@"
echo "Subject: Re: $SUBJECT" ;;
*)
if [ ${body} ]
then echo "> $@"
else
if [ -z "$1" ]
then
body=yes
echo
echo "You wrote:"
fi
fi ;;
esac
done
}
# Main
case $opt in
-h) usage ;;
-s) split ;;
-r) reply ;;
-f) format ;;
esac
#End
---------------------------------------------------------------------
To unsubscribe, e-mail: mulinux-unsubscribe@sunsite.auc.dk
For additional commands, e-mail: mulinux-help@sunsite.auc.dk
This archive was generated by hypermail 2.1.6 : Sat Feb 08 2003 - 15:27:13 CET