t9001: style modernisation phase #3
Use write_script. The resulting patch makes it a lot easier to understand what the written script is doing. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Nov 25, 2014 at 14:21 UTC
acd72b563652b646e65f2a90668b57a854fb3d12
1 file changed
+47
-52
t/t9001-send-email.sh
+47
-52
@@ -14,17 +14,19 @@ test_expect_success $PREREQ 'prepare reference tree' '
14
'
15
16
test_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
30
git add fake.sendmail &&
31
GIT_AUTHOR_NAME="A" git commit -a -m "Second."
32
'
@@ -307,11 +309,9 @@ test_expect_success $PREREQ 'tocmd works' '
309
clean_fake_sendmail &&
310
cp $patches tocmd.patch &&
311
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
315
git send-email \
316
--from="Example <nobody@example.com>" \
317
--to-cmd=./tocmd-sed \
@@ -325,11 +325,9 @@ test_expect_success $PREREQ 'cccmd works' '
325
clean_fake_sendmail &&
326
cp $patches cccmd.patch &&
327
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
331
git send-email \
332
--from="Example <nobody@example.com>" \
333
--to=nobody@example.com \
@@ -459,10 +457,9 @@ test_expect_success $PREREQ 'In-Reply-To with --chain-reply-to' '
457
'
458
459
test_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
463
'
464
465
test_set_editor "$(pwd)/fake-editor"
@@ -598,8 +595,9 @@ EOF
595
"
596
597
test_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
601
git config sendemail.cccmd ./cccmd &&
602
test_suppression cccmd
603
'
@@ -891,10 +889,9 @@ test_expect_success $PREREQ 'utf8 Cc is rfc2047 encoded' '
889
890
test_expect_success $PREREQ '--compose adds MIME for utf8 body' '
891
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
895
GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
896
git send-email \
897
--compose --subject foo \
@@ -908,15 +905,16 @@ test_expect_success $PREREQ '--compose adds MIME for utf8 body' '
905
906
test_expect_success $PREREQ '--compose respects user mime type' '
907
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
918
GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \
919
git send-email \
920
--compose --subject foo \
@@ -972,10 +970,9 @@ test_expect_success $PREREQ 'utf8 sender is not duplicated' '
970
test_expect_success $PREREQ 'sendemail.composeencoding works' '
971
clean_fake_sendmail &&
972
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
976
GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
977
git send-email \
978
--compose --subject foo \
@@ -989,10 +986,9 @@ test_expect_success $PREREQ 'sendemail.composeencoding works' '
986
987
test_expect_success $PREREQ '--compose-encoding works' '
988
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
992
GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
993
git send-email \
994
--compose-encoding iso-8859-1 \
@@ -1008,10 +1004,9 @@ test_expect_success $PREREQ '--compose-encoding works' '
1004
test_expect_success $PREREQ '--compose-encoding overrides sendemail.composeencoding' '
1005
clean_fake_sendmail &&
1006
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
1010
GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
1011
git send-email \
1012
--compose-encoding iso-8859-2 \