Matthew Gwynne <mathew.gwynne@xxxxxxxxx> writes: > I've recently encountered 2 problems with use of the example > post-receive-mail script in contrib/hooks/post-receive-email. The script's author Andy Parkins Cc'ed. > Firstly I found that having set hooks.envelopesender, the script ended > up sending mail with the envelope sender set to the email address > given literally surrounded by single quotes which caused the mail > server to complain about invalid address syntax. > ... > diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email > index c589a39..a733d0c 100644 > --- a/contrib/hooks/post-receive-email > +++ b/contrib/hooks/post-receive-email > @@ -608,7 +608,7 @@ if [ -n "$1" -a -n "$2" -a -n "$3" ]; then > PAGER= generate_email $2 $3 $1 > else > if [ -n "$envelopesender" ]; then > - envelopesender="-f '$envelopesender'" > + envelopesender="-f \"$envelopesender\"" > fi > > while read oldrev newrev refname I do not think this is a correct fix either. Suppose you have envelope sender "A B <c@xxxx>" and have original or your version to massage that string. A few lines below the part you quoted does this: /usr/sbin/sendmail -t $envelopesender which would expand and split at $IFS into /usr/sbin/sendmail -t -f 'A B <c@xxxx>' $0 $1 $2 $3 $4 $5 which is wrong, but then your fixed version would read as: /usr/sbin/sendmail -t -f '"A B <c@xxxx>"' $0 $1 $2 $3 $4 $5 which looks just as wrong. Perhaps you would need something like this (untested) patch. --- contrib/hooks/post-receive-email | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-) diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email index c589a39..f1efd5f 100644 --- a/contrib/hooks/post-receive-email +++ b/contrib/hooks/post-receive-email @@ -607,13 +607,10 @@ if [ -n "$1" -a -n "$2" -a -n "$3" ]; then # resend an email; they could redirect the output to sendmail themselves PAGER= generate_email $2 $3 $1 else - if [ -n "$envelopesender" ]; then - envelopesender="-f '$envelopesender'" - fi - while read oldrev newrev refname do generate_email $oldrev $newrev $refname | - /usr/sbin/sendmail -t $envelopesender + /usr/sbin/sendmail -t ${envelopesender:+"-f"} \ + ${envelopesender:+"$envelopesender"} done fi - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html