"David D. Kilzer" [off-list ref] writes:
+replace_header () {
+ EXPECTED=expected-show-all-headers &&
+ ACTUAL=actual-show-all-headers &&
+ REPLACEMENT=`cat ${ACTUAL} | grep "^$1:"` &&
+ if [ ! -z "${REPLACEMENT}" ]; then \
+ cat ${EXPECTED} | sed -e "s/^$1: .*\$/${REPLACEMENT}/" > ${EXPECTED}.$$ && \
+ mv -f ${EXPECTED}.$$ ${EXPECTED}
+ fi
+}
If the actual output did not have an asked-for field,
REPLACEMENT will be empty and the breakage will go unnoticed,
won't it?
It would probably be better to write it this way:
test_expect_success 'Show all headers' '
git send-email \
--dry-run \
--from="Example [off-list ref]" \
--to=to@example.com \
--cc=cc@example.com \
--bcc=bcc@example.com \
--in-reply-to="[off-list ref]" \
--smtp-sever relay.example.com \
$patches |
sed -e "s/^\(Date:\).*/1 DATE-STRING/" \
-e "s/^\(Message-Id:\).*/1 ID-STRING/" \
-e "s/^\(X-Mailer:\).*/1 X-MAILER-STRING/" \
>actual &&
diff -u expected actual
'
and prepare the expected output with the varying field already
replaced with the placeholder string.
Oh, by the way, do not cat a single file and pipe it to another
command. There may still be a few such stupidity in our test
scripts but let's not add even more of them...