[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Quilt-dev] [patch 1/1] Add --no-intro option to quilt mail (take 2)
From: |
syrjala |
Subject: |
[Quilt-dev] [patch 1/1] Add --no-intro option to quilt mail (take 2) |
Date: |
Sun, 17 Sep 2006 18:03:53 +0300 |
User-agent: |
quilt/0.45-1 |
Add a new --no-intro option to quilt mail to comply with akpm's
"The perfect patch" guidelines.
Changes to the previous version include:
- Don't complain if Subject is missing when using --no-intro
- Add a warning about --no-intro when editing the message
- Don't allow editing of Date, Message-Id, User-Agent headers.
- Don't allow editing of signature since it can't be edited for the patch
messages anyway. Maybe it would make sense to allow editing and use the
edited version for all messages...
---
quilt/mail.in | 111 +++++++++++++++++++++++++++++++++++++++-------------------
1 file changed, 75 insertions(+), 36 deletions(-)
Index: quilt/quilt/mail.in
===================================================================
--- quilt.orig/quilt/mail.in
+++ quilt/quilt/mail.in
@@ -21,7 +21,7 @@ fi
usage()
{
- printf $"Usage: quilt mail {--mbox file|--send} [-m text] [--prefix
prefix] [--sender ...] [--from ...] [--to ...] [--cc ...] [--bcc ...]
[--subject ...]\n"
+ printf $"Usage: quilt mail {--mbox file|--send} [-m text] [--prefix
prefix] [--sender ...] [--from ...] [--to ...] [--cc ...] [--bcc ...]
[--subject ...] [--no-intro]\n"
if [ x$1 = x-h ]
then
printf $"
@@ -55,6 +55,9 @@ with a template for the introduction. Pl
--to, --cc, --bcc
Append a recipient to the To, Cc, or Bcc header.
+
+--no-intro
+ Do not send the introduction message.
" "@DOCSUBDIR@/README.MAIL"
exit 0
else
@@ -94,7 +97,7 @@ process_mail()
options=`getopt -o m:h --long from:,to:,cc:,bcc:,subject: \
--long send,mbox:,charset:,sender: \
- --long prefix: -- "$@"`
+ --long prefix:,no-intro -- "$@"`
if [ $? -ne 0 ]
then
@@ -140,6 +143,9 @@ do
--charset)
opt_charset=$2
shift 2 ;;
+ --no-intro)
+ opt_no_intro=1
+ shift ;;
-h)
usage -h ;;
--)
@@ -330,27 +336,34 @@ if [ address@hidden -ne 0 ]; then
fi
introduction="$(gen_tempfile)"
-(
- cat <<-EOF
- Message-Id: <$(msgid)>
- User-Agent: quilt/@address@hidden@RELEASE@
- Date: $(date --rfc-822)
- From: ${opt_from:-$opt_sender}
- To: $(IFS=,; echo "${opt_to[*]}")
- Cc: $(IFS=,; echo "${opt_cc[*]}")
- Bcc: $(IFS=,; echo "${opt_bcc[*]}")
- Subject-Prefix: [$opt_prefix @num@/@address@hidden
- Subject: $opt_subject
- EOF
- if [ -n "$opt_message" ]
- then
- echo "$opt_message"
- echo
- fi
- echo "-- "
- [ -r $HOME/.signature ] && cat $HOME/.signature
-) | $QUILT_DIR/scripts/edmail --charset $opt_charset > $introduction
+if [ -n "$opt_no_intro" ]; then
+ ( cat <<-EOF
+ From: ${opt_from:-$opt_sender}
+ To: $(IFS=,; echo "${opt_to[*]}")
+ Cc: $(IFS=,; echo "${opt_cc[*]}")
+ Bcc: $(IFS=,; echo "${opt_bcc[*]}")
+ Subject-Prefix: [$opt_prefix @num@/@address@hidden
+
+ [--no-intro: Anything written here will be lost.]
+ EOF
+ ) | $QUILT_DIR/scripts/edmail --charset $opt_charset > $introduction
+else
+ ( cat <<-EOF
+ From: ${opt_from:-$opt_sender}
+ To: $(IFS=,; echo "${opt_to[*]}")
+ Cc: $(IFS=,; echo "${opt_cc[*]}")
+ Bcc: $(IFS=,; echo "${opt_bcc[*]}")
+ Subject-Prefix: [$opt_prefix @num@/@address@hidden
+ Subject: $opt_subject
+
+ EOF
+ if [ -n "$opt_message" ]
+ then
+ echo "$opt_message"
+ fi
+ ) | $QUILT_DIR/scripts/edmail --charset $opt_charset > $introduction
+fi
if [ -z "$opt_message" ]
then
@@ -360,7 +373,22 @@ then
fi
fi
-if [ -z "$(sed -n -e '/^$/q' \
+tmpfile=$(gen_tempfile)
+( cat <<-EOF
+ Message-Id: <$(msgid)>
+ User-Agent: quilt/@address@hidden@RELEASE@
+ Date: $(date --rfc-822)
+ EOF
+ if [ -n "$opt_no_intro" ]; then
+ echo "Subject: "
+ fi
+ cat $introduction
+) | $QUILT_DIR/scripts/edmail --charset $opt_charset > $tmpfile
+cat $tmpfile > $introduction
+rm -f $tmpfile
+
+if [ -z "$opt_no_intro" -a \
+ -z "$(sed -n -e '/^$/q' \
-e $'s/^Subject:[ \t]*//ip' \
$introduction)" ]
then
@@ -384,14 +412,19 @@ subject_prefix=$(sed -ne $'s/^Subject-Pr
subject_prefix=${subject_prefix//\'/\'\'}
subject_prefix=${subject_prefix//\//\\\/}
-p=${subject_prefix//@num@/$(printf %0*d ${#total} 0)}
-p=${p//@total@/$total}
-sed -e $'s/^\\(Subject:[ \t]\\)/\\1'"$p"'/' \
- -e '/^Subject-Prefix:/d' \
-$introduction \
-| $QUILT_DIR/scripts/edmail --charset $opt_charset \
- --remove-empty-headers To Cc Bcc \
-| process_mail
+
+if [ -z "$opt_no_intro" ]; then
+ p=${subject_prefix//@num@/$(printf %0*d ${#total} 0)}
+ p=${p//@total@/$total}
+ ( sed -e $'s/^\\(Subject:[ \t]\\)/\\1'"$p"'/' \
+ -e '/^Subject-Prefix:/d' \
+ $introduction
+ echo -e '\n-- '
+ [ -r $HOME/.signature ] && cat $HOME/.signature
+ ) | $QUILT_DIR/scripts/edmail --charset $opt_charset \
+ --remove-empty-headers To Cc Bcc \
+ | process_mail
+fi
if [ -n "$opt_mbox" ]; then
exec 1>> $opt_mbox
@@ -432,11 +465,17 @@ for patch in "address@hidden"; do
' $body)"
p=${subject_prefix//@num@/$(printf %0*d ${#total} $num)}
p=${p//@total@/$total}
- ( echo "Message-Id: <$(msgid)>"
- sed -n -e '/^$/q' \
- -e 's/^Message-Id:/References:/' \
- -e p \
- $introduction
+ ( if [ -n "$opt_no_intro" -a $num -eq 1 ]; then
+ sed -n -e '/^$/q' \
+ -e p \
+ $introduction
+ else
+ echo "Message-Id: <$(msgid)>"
+ sed -n -e '/^$/q' \
+ -e 's/^Message-Id:/References:/' \
+ -e p \
+ $introduction
+ fi
echo "Content-Disposition: inline; filename=$patch"
sed -n -e '/^$/q' \
-e '/^Recipient-.*:/d' \
--
Ville Syrjälä
address@hidden
http://www.sci.fi/~syrjala/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Quilt-dev] [patch 1/1] Add --no-intro option to quilt mail (take 2),
syrjala <=