diff options
author | Andreas Gruenbacher <agruen@suse.de> | 2007-10-29 19:38:24 +0000 |
---|---|---|
committer | Andreas Gruenbacher <agruen@suse.de> | 2007-10-29 19:38:24 +0000 |
commit | 3278efea39b8c208c6fb959c648d9627548aa6d6 (patch) | |
tree | 18ae06908f23beb8a06712d1ddad78beb05a632b /quilt | |
parent | 456c3cedca10fe75f822f9d287e5e4e08282efbb (diff) | |
download | quilt-3278efea39b8c208c6fb959c648d9627548aa6d6.tar.gz |
- quilt/mail.in: Ran into a bash ``Broken pipe'' problem in
quilt_mail_patch_filter() which I cannot explain or cleanly
reproduce. Work around it by not using pipes and subshells as
extensively here.
Diffstat (limited to 'quilt')
-rw-r--r-- | quilt/mail.in | 66 |
1 files changed, 29 insertions, 37 deletions
diff --git a/quilt/mail.in b/quilt/mail.in index 953253e..44c1638 100644 --- a/quilt/mail.in +++ b/quilt/mail.in @@ -288,60 +288,55 @@ fi if [ "$(type -t quilt_mail_patch_filter 2> /dev/null)" != function ] then quilt_mail_patch_filter() { - local patch=$(cat) - local header=$(echo "$patch" | patch_header) body subject + local tmpdir=$(gen_tempfile -d) + cat > $tmpdir/patch + patch_header < $tmpdir/patch > $tmpdir/header + local subject local -a mh # Does this patch have a Subject: line? - subject=$(echo "$header" | formail -x Subject:) + subject=$(formail -x Subject: < $tmpdir/header) if [ -n "$subject" ] then - body=$(echo "$patch" | awk ' - in_body { print } - /^$/ { in_body = 1 } - ') + awk ' + in_body { print } + /^$/ { in_body = 1 } + ' $tmpdir/patch > $tmpdir/body fi # Does this patch have DESC // subject // EDESC? if [ -z "$subject" ] then - local desc=$(echo "$header" | awk ' + local desc=$(awk ' /^EDESC\>/ { desc = 0 } desc { print } /^DESC\>/ { desc = 1 } - ') + ' $tmpdir/header) if [ -n "$desc" ] then subject=$(echo "$desc" | join_lines) - body=$(echo "$patch" | awk ' - /^DESC/ { desc = 1 } - ! desc { print } - /^EDESC/ { desc = 0 } - ') + awk ' + /^DESC/ { desc = 1 } + ! desc { print } + /^EDESC/ { desc = 0 } + ' $tmpdir/patch > $tmpdir/body fi fi # Is the first paragraph short enough to be used as the subject? if [ -z "$subject" ] then - local para=$(echo "$header" | sed -e $'/^[ \t]*$/q') + local para=$(sed -e $'/^[ \t]*$/q' $tmpdir/header) if [ ${#para} -gt 0 -a ${#para} -lt 150 ] then subject=$(echo "$para" | join_lines) - body="$(echo "$patch" | awk ' - in_body { print } - /^[ \t]*$/ { in_body = 1 } - ')" + awk ' + in_body { print } + /^[ \t]*$/ { in_body = 1 } + ' $tmpdir/patch > $tmpdir/body fi fi - #if ${#mh[@]} -eq 0 ] - #then - # # Use the patch name as the subject. - # mh=( "Replace-Subject: $1" ) - # body=$patch - #fi - if [ -z "$subject" ] then return 1 @@ -349,20 +344,17 @@ then subject=$(echo "$subject" \ | sed -e $'s/^\\(\\(\\[[^]]*\\]\\|fwd:\\|fw:\\|re:\\|aw:\\|tr:\\)[ \t]*\\)*//i') - mh=( "Replace-Subject: $subject" ) + echo "Replace-Subject: $subject" # Add recipients defined by some recognized keywords - local saved_IFS=$IFS; IFS=$'\n' - mh=( "${mh[@]}" - $(echo "$header" \ - | sed -n -e "/\<${LOGNAME:-$(whoami)}@/d" \ - -e 's/^\(To\|Cc\):/Recipient-\1:/ip' \ - -e 's/^\(Signed-off-by\|Acked-by\):/Recipient-Cc:/ip') ) - IFS=$saved_IFS - - printf "%s\n" "${mh[@]}" + sed -n -e "/\<${LOGNAME:-$(whoami)}@/d" \ + -e 's/^\(To\|Cc\):/Recipient-\1:/ip' \ + -e 's/^\(Signed-off-by\|Acked-by\):/Recipient-Cc:/ip' \ + $tmpdir/header + echo - echo "$body" + cat $tmpdir/body + rm -rf $tmpdir } fi |