@@ -14,17 +14,19 @@ test_expect_success $PREREQ 'prepare reference tree' '
1414'
1515
1616test_expect_success $PREREQ ' Setup helper tool' '
17- (echo "#!$SHELL_PATH"
18- echo shift
19- echo output=1
20- echo "while test -f commandline\$output; do output=\$((\$output+1)); done"
21- echo for a
22- echo do
23- echo " echo \"!\$a!\""
24- echo "done >commandline\$output"
25- echo "cat > msgtxt\$output"
26- ) >fake.sendmail &&
27- chmod +x ./fake.sendmail &&
17+ write_script fake.sendmail <<-\EOF &&
18+ shift
19+ output=1
20+ while test -f commandline$output
21+ do
22+ output=$(($output+1))
23+ done
24+ for a
25+ do
26+ echo "!$a!"
27+ done >commandline$output
28+ cat >"msgtxt$output"
29+ EOF
2830 git add fake.sendmail &&
2931 GIT_AUTHOR_NAME="A" git commit -a -m "Second."
3032'
@@ -307,11 +309,9 @@ test_expect_success $PREREQ 'tocmd works' '
307309 clean_fake_sendmail &&
308310 cp $patches tocmd.patch &&
309311 echo tocmd--tocmd@example.com >>tocmd.patch &&
310- {
311- echo "#!$SHELL_PATH"
312- echo sed -n -e s/^tocmd--//p \"\$1\"
313- } > tocmd-sed &&
314- chmod +x tocmd-sed &&
312+ write_script tocmd-sed <<-\EOF &&
313+ sed -n -e "s/^tocmd--//p" "$1"
314+ EOF
315315 git send-email \
316316 --from="Example <nobody@example.com>" \
317317 --to-cmd=./tocmd-sed \
@@ -325,11 +325,9 @@ test_expect_success $PREREQ 'cccmd works' '
325325 clean_fake_sendmail &&
326326 cp $patches cccmd.patch &&
327327 echo "cccmd-- cccmd@example.com" >>cccmd.patch &&
328- {
329- echo "#!$SHELL_PATH"
330- echo sed -n -e s/^cccmd--//p \"\$1\"
331- } > cccmd-sed &&
332- chmod +x cccmd-sed &&
328+ write_script cccmd-sed <<-\EOF &&
329+ sed -n -e "s/^cccmd--//p" "$1"
330+ EOF
333331 git send-email \
334332 --from="Example <nobody@example.com>" \
335333 --to=nobody@example.com \
@@ -459,10 +457,9 @@ test_expect_success $PREREQ 'In-Reply-To with --chain-reply-to' '
459457'
460458
461459test_expect_success $PREREQ ' setup fake editor' '
462- (echo "#!$SHELL_PATH" &&
463- echo "echo fake edit >>\"\$1\""
464- ) >fake-editor &&
465- chmod +x fake-editor
460+ write_script fake-editor <<-\EOF
461+ echo fake edit >>"$1"
462+ EOF
466463'
467464
468465test_set_editor " $( pwd) /fake-editor"
598595"
599596
600597test_expect_success $PREREQ ' sendemail.cccmd' '
601- echo echo cc-cmd@example.com > cccmd &&
602- chmod +x cccmd &&
598+ write_script cccmd <<-\EOF &&
599+ echo cc-cmd@example.com
600+ EOF
603601 git config sendemail.cccmd ./cccmd &&
604602 test_suppression cccmd
605603'
@@ -891,10 +889,9 @@ test_expect_success $PREREQ 'utf8 Cc is rfc2047 encoded' '
891889
892890test_expect_success $PREREQ ' --compose adds MIME for utf8 body' '
893891 clean_fake_sendmail &&
894- (echo "#!$SHELL_PATH" &&
895- echo "echo utf8 body: àéìöú >>\"\$1\""
896- ) >fake-editor-utf8 &&
897- chmod +x fake-editor-utf8 &&
892+ write_script fake-editor-utf8 <<-\EOF &&
893+ echo "utf8 body: àéìöú" >>"$1"
894+ EOF
898895 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
899896 git send-email \
900897 --compose --subject foo \
@@ -908,15 +905,16 @@ test_expect_success $PREREQ '--compose adds MIME for utf8 body' '
908905
909906test_expect_success $PREREQ ' --compose respects user mime type' '
910907 clean_fake_sendmail &&
911- (echo "#!$SHELL_PATH" &&
912- echo "(echo MIME-Version: 1.0"
913- echo " echo Content-Type: text/plain\\; charset=iso-8859-1"
914- echo " echo Content-Transfer-Encoding: 8bit"
915- echo " echo Subject: foo"
916- echo " echo "
917- echo " echo utf8 body: àéìöú) >\"\$1\""
918- ) >fake-editor-utf8-mime &&
919- chmod +x fake-editor-utf8-mime &&
908+ write_script fake-editor-utf8-mime <<-\EOF &&
909+ cat >"$1" <<-\EOM
910+ MIME-Version: 1.0
911+ Content-Type: text/plain; charset=iso-8859-1
912+ Content-Transfer-Encoding: 8bit
913+ Subject: foo
914+
915+ utf8 body: àéìöú
916+ EOM
917+ EOF
920918 GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \
921919 git send-email \
922920 --compose --subject foo \
@@ -972,10 +970,9 @@ test_expect_success $PREREQ 'utf8 sender is not duplicated' '
972970test_expect_success $PREREQ ' sendemail.composeencoding works' '
973971 clean_fake_sendmail &&
974972 git config sendemail.composeencoding iso-8859-1 &&
975- (echo "#!$SHELL_PATH" &&
976- echo "echo utf8 body: àéìöú >>\"\$1\""
977- ) >fake-editor-utf8 &&
978- chmod +x fake-editor-utf8 &&
973+ write_script fake-editor-utf8 <<-\EOF &&
974+ echo "utf8 body: àéìöú" >>"$1"
975+ EOF
979976 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
980977 git send-email \
981978 --compose --subject foo \
@@ -989,10 +986,9 @@ test_expect_success $PREREQ 'sendemail.composeencoding works' '
989986
990987test_expect_success $PREREQ ' --compose-encoding works' '
991988 clean_fake_sendmail &&
992- (echo "#!$SHELL_PATH" &&
993- echo "echo utf8 body: àéìöú >>\"\$1\""
994- ) >fake-editor-utf8 &&
995- chmod +x fake-editor-utf8 &&
989+ write_script fake-editor-utf8 <<-\EOF &&
990+ echo "utf8 body: àéìöú" >>"$1"
991+ EOF
996992 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
997993 git send-email \
998994 --compose-encoding iso-8859-1 \
@@ -1008,10 +1004,9 @@ test_expect_success $PREREQ '--compose-encoding works' '
10081004test_expect_success $PREREQ ' --compose-encoding overrides sendemail.composeencoding' '
10091005 clean_fake_sendmail &&
10101006 git config sendemail.composeencoding iso-8859-1 &&
1011- (echo "#!$SHELL_PATH" &&
1012- echo "echo utf8 body: àéìöú >>\"\$1\""
1013- ) >fake-editor-utf8 &&
1014- chmod +x fake-editor-utf8 &&
1007+ write_script fake-editor-utf8 <<-\EOF &&
1008+ echo "utf8 body: àéìöú" >>"$1"
1009+ EOF
10151010 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
10161011 git send-email \
10171012 --compose-encoding iso-8859-2 \
0 commit comments