On Τρι, Μάρ 06, at 02:24 Ag. Hatzimanikas wrote:
> Just to be in sync with LFS,the first attachment is to update vim in 198
> patchlevel,although we are now in 207.
> The second patch is just this small diff about the vimrc page.
>
Because lately I made this habit to forget to send the attachment(s) (like in
the original replying message), here is the solution for the mutt users.
Note:
Keep in mind that there is already a patch for this purpose but I am not
sure it will be ever included in the official distribution. I think not.
See #1484 in mutt.org.
Until then, there is a simple solution for the X environment.
http://wiki.mutt.org/?ConfigTricks/CheckAttach
Attached is the same script with some minor changes and also to make it work
with xmessage.
Plus is a good chance to test if it really works.
What this script do:
a) First it checks if it is running in X environment; If not, it just send the
message using the sendmail variable. Change this variable at your will.
b) It checks if the message is a multipart message, and if it is, then it just
send the message.
c) It checks the headers (subject mainly) and the body of the message -but not
the quoted text- for some common words like; (patch - attached - attachment)
Again change them at your will.
If it finds one of these words then it will ask -with a xmessage box- for
confirmation. If the answer is yes, returns true and send the
message, else it exits and you have then the chance to attach the
patch -and not to look like a fool.
I will omit to attach the script right now.
If you don't receive an attachment, I maybe will read again the bash-scripting
guide.
-------------- next part --------------
#!/bin/sh
SENDMAIL=/usr/bin/esmtp
[[ -z "$DISPLAY" ]] && $SENDMAIL "$@"
###
# save msg in file to re-use it for multiple tests
###
t=`mktemp -t mutt.XXXXXX` || exit 2
cat > $t
###
# define tests for: anything you can think of can be done.
# the return code of last exec'ed cmd is used in final decision below
###
multipart(){
grep -q '^Content-Type: multipart' $t
}
word_attach(){
grep -v '^>' $t | grep -Eq '(attachment|patch|attached)'
}
###
# query function must return "true" to let the msg pass.
###
ask(){
Message="You didn't include any attachment!
Idiot!
Send it anyway?"
Answer=$(xmessage -name "PATCH" -bg red -fg white -nearmouse \
"$Message" -buttons yes,no -print)
[[ "$Answer" == "yes" ]] && return 0 || return 1
}
###
# FINAL DECISION:
# chain series of functions, use ! || && for logic connections,
# see "man $SHELL" for more possibilites like grouping, dependencies.
###
if multipart || ! word_attach || ask; then
$SENDMAIL "$@" < $t
status=$?
else
status=1
fi
rm -f $t
exit $status