(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:test_description)
          op: assign_op.Equal
          rhs: {(SQ <'git send-email'>)}
          spids: [4]
        )
      ]
    )
    (C {<.>} {<'./test-lib.sh'>})
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:PREREQ)
          op: assign_op.Equal
          rhs: {(DQ <PERL>)}
          spids: [17]
        )
      ]
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'prepare reference tree'>)} 
      {
        (SQ <'\n'> <'\techo "1A quick brown fox jumps over the" >file &&\n'> 
          <'\techo "lazy dog" >>file &&\n'> <'\tgit add file &&\n'> <'\tGIT_AUTHOR_NAME="A" git commit -a -m "Initial."\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'Setup helper tool'>)} 
      {
        (SQ <'\n'> <'\twrite_script fake.sendmail <<-\\EOF &&\n'> <'\tshift\n'> <'\toutput=1\n'> 
          <'\twhile test -f commandline$output\n'> <'\tdo\n'> <'\t\toutput=$(($output+1))\n'> <'\tdone\n'> <'\tfor a\n'> <'\tdo\n'> <'\t\techo "!$a!"\n'> 
          <'\tdone >commandline$output\n'> <'\tcat >"msgtxt$output"\n'> <'\tEOF\n'> <'\tgit add fake.sendmail &&\n'> 
          <'\tGIT_AUTHOR_NAME="A" git commit -a -m "Second."\n'>
        )
      }
    )
    (command.ShFunction
      name: clean_fake_sendmail
      body: 
        (BraceGroup
          children: [(C {<rm>} {<-f>} {<commandline> <Id.Lit_Star '*'>} {<msgtxt> <Id.Lit_Star '*'>})]
        )
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'Extract patches'>)} 
      {
        (SQ <'\n'> 
          <
'\tpatches=$(git format-patch -s --cc="One <one@example.com>" --cc=two@example.com -n HEAD^1)\n'
          >
        )
      }
    )
    (command.ShFunction
      name: test_no_confirm
      body: 
        (BraceGroup
          children: [
            (C {<rm>} {<-f>} {<no_confirm_okay>})
            (command.AndOr
              ops: [Id.Op_DAmp Id.Op_DAmp]
              children: [
                (command.Pipeline
                  children: [
                    (C {<echo>} {<n>})
                    (command.Simple
                      words: [
                        {<git>}
                        {<send-email>}
                        {<--from> <Id.Lit_Equals '='> (DQ <'Example <from@example.com>'>)}
                        {<--to> <Id.Lit_Equals '='> <nobody> <Id.Lit_Splice '@example'> <.com>}
                        {<--smtp-server> <Id.Lit_Equals '='> 
                          (DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})) 
                            <'/fake.sendmail'>
                          )
                        }
                        {($ Id.VSub_At '$@')}
                        {($ Id.VSub_DollarName '$patches')}
                      ]
                      redirects: [
                        (redir
                          op: <Id.Redir_Great '>'>
                          loc: (redir_loc.Fd fd:1)
                          arg: {<stdout>}
                        )
                      ]
                      more_env: [(env_pair name:GIT_SEND_EMAIL_NOTTY val:{<1>} spids:[129])]
                      do_fork: T
                    )
                  ]
                  negated: F
                )
                (C {<test_must_fail>} {<grep>} {(DQ <'Send this email'>)} {<stdout>})
                (command.Simple
                  redirects: [
                    (redir
                      op: <Id.Redir_Great '>'>
                      loc: (redir_loc.Fd fd:1)
                      arg: {<no_confirm_okay>}
                    )
                  ]
                  do_fork: F
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: check_no_confirm
      body: 
        (BraceGroup
          children: [
            (command.If
              arms: [
                (if_arm
                  cond: 
                    (condition.Shell
                      commands: [
                        (command.Pipeline
                          children: [(C {<test>} {<-f>} {<no_confirm_okay>})]
                          negated: T
                        )
                      ]
                    )
                  action: [
                    (C {<say>} 
                      {(SQ <'confirm test failed; skipping remaining tests to prevent hanging'>)}
                    )
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:PREREQ)
                          op: assign_op.Equal
                          rhs: {(DQ ($ Id.VSub_DollarName '$PREREQ') <',CHECK_NO_CONFIRM'>)}
                          spids: [230]
                        )
                      ]
                    )
                  ]
                  spids: [209 220]
                )
              ]
            )
            (command.ControlFlow token:<Id.ControlFlow_Return return> arg_word:{<0>})
          ]
        )
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'No confirm with --suppress-cc'>)} {(SQ <'\n'> <'\ttest_no_confirm --suppress-cc=sob &&\n'> <'\tcheck_no_confirm\n'>)}
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'No confirm with --confirm=never'>)} {(SQ <'\n'> <'\ttest_no_confirm --confirm=never &&\n'> <'\tcheck_no_confirm\n'>)}
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'No confirm with sendemail.confirm=never'>)} 
      {
        (SQ <'\n'> <'\tgit config sendemail.confirm never &&\n'> 
          <'\ttest_no_confirm --compose --subject=foo &&\n'> <'\tcheck_no_confirm\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'Send patches'>)} 
      {
        (SQ <'\n'> 
          <
'\tgit send-email --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors\n'
          >
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'setup expect'>)} 
      {
        (SQ <'\n'> <'\tcat >expected <<-\\EOF\n'> <'\t!nobody@example.com!\n'> 
          <'\t!author@example.com!\n'> <'\t!one@example.com!\n'> <'\t!two@example.com!\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'Verify commandline'>)} 
      {(SQ <'\n'> <'\ttest_cmp expected commandline1\n'>)}
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'Send patches with --envelope-sender'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> 
          <
'\tgit send-email --envelope-sender="Patch Contributor <patch@example.com>" --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors\n'
          >
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'setup expect'>)} 
      {
        (SQ <'\n'> <'\tcat >expected <<-\\EOF\n'> <'\t!patch@example.com!\n'> <'\t!-i!\n'> 
          <'\t!nobody@example.com!\n'> <'\t!author@example.com!\n'> <'\t!one@example.com!\n'> <'\t!two@example.com!\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'Verify commandline'>)} 
      {(SQ <'\n'> <'\ttest_cmp expected commandline1\n'>)}
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'Send patches with --envelope-sender=auto'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> 
          <
'\tgit send-email --envelope-sender=auto --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors\n'
          >
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'setup expect'>)} 
      {
        (SQ <'\n'> <'\tcat >expected <<-\\EOF\n'> <'\t!nobody@example.com!\n'> <'\t!-i!\n'> 
          <'\t!nobody@example.com!\n'> <'\t!author@example.com!\n'> <'\t!one@example.com!\n'> <'\t!two@example.com!\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'Verify commandline'>)} 
      {(SQ <'\n'> <'\ttest_cmp expected commandline1\n'>)}
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'setup expect for cc trailer'>)} 
      {
        (DQ <'\n'> <'cat >expected-cc <<'> <Id.Lit_BadBackslash '\\'> <'EOF\n'> 
          <'!recipient@example.com!\n'> <'!author@example.com!\n'> <'!one@example.com!\n'> <'!two@example.com!\n'> <'!three@example.com!\n'> 
          <'!four@example.com!\n'> <'!five@example.com!\n'> <'EOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'cc trailer with various syntax'>)} 
      {
        (SQ <'\n'> <'\ttest_commit cc-trailer &&\n'> 
          <'\ttest_when_finished "git reset --hard HEAD^" &&\n'> <'\tgit commit --amend -F - <<-EOF &&\n'> <'\tTest Cc: trailers.\n'> <'\n'> <'\tCc: one@example.com\n'> 
          <'\tCc: <two@example.com> # this is part of the name\n'> <'\tCc: <three@example.com>, <four@example.com> # not.five@example.com\n'> 
          <'\tCc: "Some # Body" <five@example.com> [part.of.name.too]\n'> <'\tEOF\n'> <'\tclean_fake_sendmail &&\n'> <'\tgit send-email -1 --to=recipient@example.com \\\n'> 
          <'\t\t--smtp-server="$(pwd)/fake.sendmail" &&\n'> <'\ttest_cmp expected-cc commandline1\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'setup expect'>)} 
      {
        (DQ <'\n'> <'cat >expected-show-all-headers <<'> <Id.Lit_BadBackslash '\\'> <'EOF\n'> 
          <'0001-Second.patch\n'> <'(mbox) Adding cc: A <author@example.com> from line \'From: A <author@example.com>\'\n'> 
          <
'(mbox) Adding cc: One <one@example.com> from line \'Cc: One <one@example.com>, two@example.com\'\n'
          > <'(mbox) Adding cc: two@example.com from line \'Cc: One <one@example.com>, two@example.com\'\n'> 
          <'Dry-OK. Log says:\n'> <'Server: relay.example.com\n'> <'MAIL FROM:<from@example.com>\n'> <'RCPT TO:<to@example.com>\n'> 
          <'RCPT TO:<cc@example.com>\n'> <'RCPT TO:<author@example.com>\n'> <'RCPT TO:<one@example.com>\n'> <'RCPT TO:<two@example.com>\n'> 
          <'RCPT TO:<bcc@example.com>\n'> <'From: Example <from@example.com>\n'> <'To: to@example.com\n'> <'Cc: cc@example.com,\n'> 
          <'\tA <author@example.com>,\n'> <'\tOne <one@example.com>,\n'> <'\ttwo@example.com\n'> <'Subject: [PATCH 1/1] Second.\n'> 
          <'Date: DATE-STRING\n'> <'Message-Id: MESSAGE-ID-STRING\n'> <'X-Mailer: X-MAILER-STRING\n'> 
          <'In-Reply-To: <unique-message-id@example.com>\n'> <'References: <unique-message-id@example.com>\n'> <'\n'> <'Result: OK\n'> <'EOF\n'>
        )
      }
    )
    (command.ShFunction
      name: test_suppress_self
      body: 
        (BraceGroup
          children: [
            (command.AndOr
              ops: [
                Id.Op_DAmp
                Id.Op_DAmp
                Id.Op_DAmp
                Id.Op_DAmp
                Id.Op_DAmp
                Id.Op_DAmp
                Id.Op_DAmp
                Id.Op_DAmp
                Id.Op_DAmp
                Id.Op_DAmp
              ]
              children: [
                (C {<test_commit>} {($ Id.VSub_Number '$3')})
                (C {<test_when_finished>} {(DQ <'git reset --hard HEAD^'>)})
                (command.Simple
                  words: [{<write_script>} {<cccmd-sed>}]
                  redirects: [
                    (redir
                      op: <Id.Redir_DLessDash '<<-'>
                      loc: (redir_loc.Fd fd:0)
                      arg: 
                        (redir_param.HereDoc
                          here_begin: {<EOF>}
                          here_end_span_id: 583
                          stdin_parts: [
                            <'sed -n -e s/^cccmd--//p '>
                            <Id.Right_DoubleQuote '"'>
                            (word_part.EscapedLiteral
                              token: <Id.Lit_EscapedChar '\\$'>
                            )
                            <1>
                            <Id.Right_DoubleQuote '"'>
                            <'\n'>
                          ]
                        )
                    )
                  ]
                  do_fork: T
                )
                (C {<git>} {<commit>} {<--amend>} 
                  {<--author> <Id.Lit_Equals '='> 
                    (DQ ($ Id.VSub_Number '$1') <' <'> ($ Id.VSub_Number '$2') <'>'>)
                  } {<-F>} {<->}
                )
                (C {<clean_fake_sendmail>})
                (command.Simple
                  words: [{<git>} {<format-patch>} {<--stdout>} {<-1>}]
                  redirects: [
                    (redir
                      op: <Id.Redir_Great '>'>
                      loc: (redir_loc.Fd fd:1)
                      arg: {(DQ <suppress-self-> ($ Id.VSub_Number '$3') <.patch>)}
                    )
                  ]
                  do_fork: T
                )
                (C {<git>} {<send-email>} 
                  {<--from> <Id.Lit_Equals '='> 
                    (DQ ($ Id.VSub_Number '$1') <' <'> ($ Id.VSub_Number '$2') <'>'>)
                  } {<--to> <Id.Lit_Equals '='> <nobody> <Id.Lit_Splice '@example'> <.com>} 
                  {<--cc-cmd> <Id.Lit_Equals '='> <'./cccmd-sed'>} {<--suppress-cc> <Id.Lit_Equals '='> <self>} 
                  {<--smtp-server> <Id.Lit_Equals '='> 
                    (DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})) 
                      <'/fake.sendmail'>
                    )
                  } {<suppress-self-> ($ Id.VSub_Number '$3') <.patch>}
                )
                (C {<mv>} {<msgtxt1>} {<msgtxt1-> ($ Id.VSub_Number '$3')})
                (command.Simple
                  words: [{<sed>} {<-e>} {(SQ <'/^$/q'>)} {<msgtxt1-> ($ Id.VSub_Number '$3')}]
                  redirects: [
                    (redir
                      op: <Id.Redir_Great '>'>
                      loc: (redir_loc.Fd fd:1)
                      arg: {(DQ <msghdr1-> ($ Id.VSub_Number '$3'))}
                    )
                  ]
                  do_fork: T
                )
                (command.Simple
                  redirects: [
                    (redir
                      op: <Id.Redir_Great '>'>
                      loc: (redir_loc.Fd fd:1)
                      arg: {(DQ <expected-no-cc-> ($ Id.VSub_Number '$3'))}
                    )
                  ]
                  do_fork: F
                )
                (command.Subshell
                  child: 
                    (command.CommandList
                      children: [
                        (command.Sentence
                          child: 
                            (command.Simple
                              words: [{<grep>} {(SQ <'^Cc:'>)} {<msghdr1-> ($ Id.VSub_Number '$3')}]
                              redirects: [
                                (redir
                                  op: <Id.Redir_Great '>'>
                                  loc: (redir_loc.Fd fd:1)
                                  arg: {(DQ <actual-no-cc-> ($ Id.VSub_Number '$3'))}
                                )
                              ]
                              do_fork: T
                            )
                          terminator: <Id.Op_Semi _>
                        )
                        (C {<test_cmp>} {<expected-no-cc-> ($ Id.VSub_Number '$3')} 
                          {<actual-no-cc-> ($ Id.VSub_Number '$3')}
                        )
                      ]
                    )
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: test_suppress_self_unquoted
      body: 
        (BraceGroup
          children: [
            (command.Simple
              words: [
                {<test_suppress_self>}
                {(DQ ($ Id.VSub_Number '$1'))}
                {(DQ ($ Id.VSub_Number '$2'))}
                {(DQ <unquoted-> ($ Id.VSub_Number '$3'))}
              ]
              redirects: [
                (redir
                  op: <Id.Redir_DLessDash '<<-'>
                  loc: (redir_loc.Fd fd:0)
                  arg: 
                    (redir_param.HereDoc
                      here_begin: {<EOF>}
                      here_end_span_id: 811
                      stdin_parts: [
                        <'test suppress-cc.self unquoted-'>
                        ($ Id.VSub_Number '$3')
                        <' with name '>
                        ($ Id.VSub_Number '$1')
                        <' email '>
                        ($ Id.VSub_Number '$2')
                        <'\n'>
                        <'\n'>
                        <unquoted->
                        ($ Id.VSub_Number '$3')
                        <'\n'>
                        <'\n'>
                        <cccmd-->
                        ($ Id.VSub_Number '$1')
                        <' <'>
                        ($ Id.VSub_Number '$2')
                        <'>\n'>
                        <'\n'>
                        <'Cc: '>
                        ($ Id.VSub_Number '$1')
                        <' <'>
                        ($ Id.VSub_Number '$2')
                        <'>\n'>
                        <'Signed-off-by: '>
                        ($ Id.VSub_Number '$1')
                        <' <'>
                        ($ Id.VSub_Number '$2')
                        <'>\n'>
                      ]
                    )
                )
              ]
              do_fork: T
            )
          ]
        )
    )
    (command.ShFunction
      name: test_suppress_self_quoted
      body: 
        (BraceGroup
          children: [
            (command.Simple
              words: [
                {<test_suppress_self>}
                {(DQ ($ Id.VSub_Number '$1'))}
                {(DQ ($ Id.VSub_Number '$2'))}
                {(DQ <quoted-> ($ Id.VSub_Number '$3'))}
              ]
              redirects: [
                (redir
                  op: <Id.Redir_DLessDash '<<-'>
                  loc: (redir_loc.Fd fd:0)
                  arg: 
                    (redir_param.HereDoc
                      here_begin: {<EOF>}
                      here_end_span_id: 886
                      stdin_parts: [
                        <'test suppress-cc.self quoted-'>
                        ($ Id.VSub_Number '$3')
                        <' with name '>
                        ($ Id.VSub_Number '$1')
                        <' email '>
                        ($ Id.VSub_Number '$2')
                        <'\n'>
                        <'\n'>
                        <quoted->
                        ($ Id.VSub_Number '$3')
                        <'\n'>
                        <'\n'>
                        <cccmd-->
                        <Id.Right_DoubleQuote '"'>
                        ($ Id.VSub_Number '$1')
                        <Id.Right_DoubleQuote '"'>
                        <' <'>
                        ($ Id.VSub_Number '$2')
                        <'>\n'>
                        <'\n'>
                        <'Cc: '>
                        ($ Id.VSub_Number '$1')
                        <' <'>
                        ($ Id.VSub_Number '$2')
                        <'>\n'>
                        <'Cc: '>
                        <Id.Right_DoubleQuote '"'>
                        ($ Id.VSub_Number '$1')
                        <Id.Right_DoubleQuote '"'>
                        <' <'>
                        ($ Id.VSub_Number '$2')
                        <'>\n'>
                        <'Signed-off-by: '>
                        ($ Id.VSub_Number '$1')
                        <' <'>
                        ($ Id.VSub_Number '$2')
                        <'>\n'>
                        <'Signed-off-by: '>
                        <Id.Right_DoubleQuote '"'>
                        ($ Id.VSub_Number '$1')
                        <Id.Right_DoubleQuote '"'>
                        <' <'>
                        ($ Id.VSub_Number '$2')
                        <'>\n'>
                      ]
                    )
                )
              ]
              do_fork: T
            )
          ]
        )
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'self name is suppressed'>)} 
      {
        (DQ <'\n'> <'\ttest_suppress_self_unquoted \'A U Thor\' \'author@example.com\' '> 
          <'\t\t\'self_name_suppressed\'\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'self name with dot is suppressed'>)} 
      {
        (DQ <'\n'> <'\ttest_suppress_self_quoted \'A U. Thor\' \'author@example.com\' '> 
          <'\t\t\'self_name_dot_suppressed\'\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'non-ascii self name is suppressed'>)} 
      {
        (DQ <'\n'> <'\ttest_suppress_self_quoted \'Füñný Nâmé\' \'odd_?=mail@example.com\' '> 
          <'\t\t\'non_ascii_self_suppressed\'\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'long non-ascii self name is suppressed'>)} 
      {
        (DQ <'\n'> 
          <
'\ttest_suppress_self_quoted \'Ƒüñníęř €. Nâṁé\' \'odd_?=mail@example.com\' '
          > <'\t\t\'long_non_ascii_self_suppressed\'\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'sanitized self name is suppressed'>)} 
      {
        (DQ <'\n'> <'\ttest_suppress_self_unquoted \''> 
          (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) <'A U. Thor'> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) 
          <'\' \'author@example.com\' '> <'\t\t\'self_name_sanitized_suppressed\'\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'Show all headers'>)} 
      {
        (SQ <'\n'> <'\tgit send-email \\\n'> <'\t\t--dry-run \\\n'> <'\t\t--suppress-cc=sob \\\n'> 
          <'\t\t--from="Example <from@example.com>" \\\n'> <'\t\t--to=to@example.com \\\n'> <'\t\t--cc=cc@example.com \\\n'> <'\t\t--bcc=bcc@example.com \\\n'> 
          <'\t\t--in-reply-to="<unique-message-id@example.com>" \\\n'> <'\t\t--smtp-server relay.example.com \\\n'> <'\t\t$patches |\n'> 
          <'\tsed\t-e "s/^\\(Date:\\).*/\\1 DATE-STRING/" \\\n'> <'\t\t-e "s/^\\(Message-Id:\\).*/\\1 MESSAGE-ID-STRING/" \\\n'> 
          <'\t\t-e "s/^\\(X-Mailer:\\).*/\\1 X-MAILER-STRING/" \\\n'> <'\t\t>actual-show-all-headers &&\n'> 
          <'\ttest_cmp expected-show-all-headers actual-show-all-headers\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'Prompting works'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\t(echo "to@example.com"\n'> <'\t echo ""\n'> 
          <'\t) | GIT_SEND_EMAIL_NOTTY=1 git send-email \\\n'> <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\t$patches \\\n'> <'\t\t2>errors &&\n'> 
          <'\t\tgrep "^From: A U Thor <author@example.com>\\$" msgtxt1 &&\n'> <'\t\tgrep "^To: to@example.com\\$" msgtxt1\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ') <Id.Lit_Comma ','> <AUTOIDENT>} 
      {(SQ <'implicit ident is allowed'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\t(sane_unset GIT_AUTHOR_NAME &&\n'> 
          <'\tsane_unset GIT_AUTHOR_EMAIL &&\n'> <'\tsane_unset GIT_COMMITTER_NAME &&\n'> <'\tsane_unset GIT_COMMITTER_EMAIL &&\n'> 
          <'\tGIT_SEND_EMAIL_NOTTY=1 git send-email \\\n'> <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\t--to=to@example.com \\\n'> 
          <'\t\t$patches </dev/null 2>errors\n'> <'\t)\n'>
        )
      }
    )
    (C {<test_expect_success>} 
      {($ Id.VSub_DollarName '$PREREQ') <Id.Lit_Comma ','> <Id.KW_Bang '!'> <AUTOIDENT>} {(SQ <'broken implicit ident aborts send-email'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\t(sane_unset GIT_AUTHOR_NAME &&\n'> 
          <'\tsane_unset GIT_AUTHOR_EMAIL &&\n'> <'\tsane_unset GIT_COMMITTER_NAME &&\n'> <'\tsane_unset GIT_COMMITTER_EMAIL &&\n'> 
          <'\tGIT_SEND_EMAIL_NOTTY=1 && export GIT_SEND_EMAIL_NOTTY &&\n'> <'\ttest_must_fail git send-email \\\n'> <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> 
          <'\t\t--to=to@example.com \\\n'> <'\t\t$patches </dev/null 2>errors &&\n'> <'\ttest_i18ngrep "tell me who you are" errors\n'> <'\t)\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'setup tocmd and cccmd scripts'>)} 
      {
        (SQ <'\n'> <'\twrite_script tocmd-sed <<-\\EOF &&\n'> <'\tsed -n -e "s/^tocmd--//p" "$1"\n'> 
          <'\tEOF\n'> <'\twrite_script cccmd-sed <<-\\EOF\n'> <'\tsed -n -e "s/^cccmd--//p" "$1"\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'tocmd works'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\tcp $patches tocmd.patch &&\n'> 
          <'\techo tocmd--tocmd@example.com >>tocmd.patch &&\n'> <'\tgit send-email \\\n'> <'\t\t--from="Example <nobody@example.com>" \\\n'> 
          <'\t\t--to-cmd=./tocmd-sed \\\n'> <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\ttocmd.patch \\\n'> <'\t\t&&\n'> 
          <'\tgrep "^To: tocmd@example.com" msgtxt1\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'cccmd works'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\tcp $patches cccmd.patch &&\n'> 
          <'\techo "cccmd--  cccmd@example.com" >>cccmd.patch &&\n'> <'\tgit send-email \\\n'> <'\t\t--from="Example <nobody@example.com>" \\\n'> 
          <'\t\t--to=nobody@example.com \\\n'> <'\t\t--cc-cmd=./cccmd-sed \\\n'> <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> 
          <'\t\tcccmd.patch \\\n'> <'\t\t&&\n'> <'\tgrep "^\tcccmd@example.com" msgtxt1\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'reject long lines'>)} 
      {
        (SQ <'\n'> <'\tz8=zzzzzzzz &&\n'> <'\tz64=$z8$z8$z8$z8$z8$z8$z8$z8 &&\n'> 
          <'\tz512=$z64$z64$z64$z64$z64$z64$z64$z64 &&\n'> <'\tclean_fake_sendmail &&\n'> <'\tcp $patches longline.patch &&\n'> 
          <'\techo $z512$z512 >>longline.patch &&\n'> <'\ttest_must_fail git send-email \\\n'> <'\t\t--from="Example <nobody@example.com>" \\\n'> 
          <'\t\t--to=nobody@example.com \\\n'> <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\t$patches longline.patch \\\n'> 
          <'\t\t2>errors &&\n'> <'\tgrep longline.patch errors\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'no patch was sent'>)} 
      {(SQ <'\n'> <'\t! test -e commandline1\n'>)}
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'Author From: in message body'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\tgit send-email \\\n'> 
          <'\t\t--from="Example <nobody@example.com>" \\\n'> <'\t\t--to=nobody@example.com \\\n'> <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> 
          <'\t\t$patches &&\n'> <'\tsed "1,/^\\$/d" <msgtxt1 >msgbody1 &&\n'> <'\tgrep "From: A <author@example.com>" msgbody1\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'Author From: not in message body'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\tgit send-email \\\n'> 
          <'\t\t--from="A <author@example.com>" \\\n'> <'\t\t--to=nobody@example.com \\\n'> <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> 
          <'\t\t$patches &&\n'> <'\tsed "1,/^\\$/d" <msgtxt1 >msgbody1 &&\n'> <'\t! grep "From: A <author@example.com>" msgbody1\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'allow long lines with --no-validate'>)} 
      {
        (SQ <'\n'> <'\tgit send-email \\\n'> <'\t\t--from="Example <nobody@example.com>" \\\n'> 
          <'\t\t--to=nobody@example.com \\\n'> <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\t--no-validate \\\n'> 
          <'\t\t$patches longline.patch \\\n'> <'\t\t2>errors\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'Invalid In-Reply-To'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\tgit send-email \\\n'> 
          <'\t\t--from="Example <nobody@example.com>" \\\n'> <'\t\t--to=nobody@example.com \\\n'> <'\t\t--in-reply-to=" " \\\n'> 
          <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\t$patches \\\n'> <'\t\t2>errors &&\n'> <'\t! grep "^In-Reply-To: < *>" msgtxt1\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'Valid In-Reply-To when prompting'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\t(echo "From Example <from@example.com>"\n'> 
          <'\t echo "To Example <to@example.com>"\n'> <'\t echo ""\n'> <'\t) | GIT_SEND_EMAIL_NOTTY=1 git send-email \\\n'> 
          <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\t$patches 2>errors &&\n'> <'\t! grep "^In-Reply-To: < *>" msgtxt1\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'In-Reply-To without --chain-reply-to'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> 
          <'\techo "<unique-message-id@example.com>" >expect &&\n'> <'\tgit send-email \\\n'> <'\t\t--from="Example <nobody@example.com>" \\\n'> 
          <'\t\t--to=nobody@example.com \\\n'> <'\t\t--no-chain-reply-to \\\n'> <'\t\t--in-reply-to="$(cat expect)" \\\n'> 
          <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\t$patches $patches $patches \\\n'> <'\t\t2>errors &&\n'> 
          <'\t# The first message is a reply to --in-reply-to\n'> <'\tsed -n -e "s/^In-Reply-To: *\\(.*\\)/\\1/p" msgtxt1 >actual &&\n'> 
          <'\ttest_cmp expect actual &&\n'> <'\t# Second and subsequent messages are replies to the first one\n'> 
          <'\tsed -n -e "s/^Message-Id: *\\(.*\\)/\\1/p" msgtxt1 >expect &&\n'> <'\tsed -n -e "s/^In-Reply-To: *\\(.*\\)/\\1/p" msgtxt2 >actual &&\n'> 
          <'\ttest_cmp expect actual &&\n'> <'\tsed -n -e "s/^In-Reply-To: *\\(.*\\)/\\1/p" msgtxt3 >actual &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'In-Reply-To with --chain-reply-to'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> 
          <'\techo "<unique-message-id@example.com>" >expect &&\n'> <'\tgit send-email \\\n'> <'\t\t--from="Example <nobody@example.com>" \\\n'> 
          <'\t\t--to=nobody@example.com \\\n'> <'\t\t--chain-reply-to \\\n'> <'\t\t--in-reply-to="$(cat expect)" \\\n'> 
          <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\t$patches $patches $patches \\\n'> <'\t\t2>errors &&\n'> 
          <'\tsed -n -e "s/^In-Reply-To: *\\(.*\\)/\\1/p" msgtxt1 >actual &&\n'> <'\ttest_cmp expect actual &&\n'> 
          <'\tsed -n -e "s/^Message-Id: *\\(.*\\)/\\1/p" msgtxt1 >expect &&\n'> <'\tsed -n -e "s/^In-Reply-To: *\\(.*\\)/\\1/p" msgtxt2 >actual &&\n'> 
          <'\ttest_cmp expect actual &&\n'> <'\tsed -n -e "s/^Message-Id: *\\(.*\\)/\\1/p" msgtxt2 >expect &&\n'> 
          <'\tsed -n -e "s/^In-Reply-To: *\\(.*\\)/\\1/p" msgtxt3 >actual &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'setup fake editor'>)} 
      {
        (SQ <'\n'> <'\twrite_script fake-editor <<-\\EOF\n'> <'\techo fake edit >>"$1"\n'> <'\tEOF\n'>)
      }
    )
    (C {<test_set_editor>} 
      {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})) <'/fake-editor'>)}
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'--compose works'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\tgit send-email \\\n'> 
          <'\t--compose --subject foo \\\n'> <'\t--from="Example <nobody@example.com>" \\\n'> <'\t--to=nobody@example.com \\\n'> 
          <'\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t$patches \\\n'> <'\t2>errors\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'first message is compose text'>)} {(SQ <'\n'> <'\tgrep "^fake edit" msgtxt1\n'>)}
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'second message is patch'>)} 
      {(SQ <'\n'> <'\tgrep "Subject:.*Second" msgtxt2\n'>)}
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'setup expect'>)} 
      {
        (DQ <'\n'> <'cat >expected-suppress-sob <<'> <Id.Lit_BadBackslash '\\'> <'EOF\n'> 
          <'0001-Second.patch\n'> <'(mbox) Adding cc: A <author@example.com> from line \'From: A <author@example.com>\'\n'> 
          <
'(mbox) Adding cc: One <one@example.com> from line \'Cc: One <one@example.com>, two@example.com\'\n'
          > <'(mbox) Adding cc: two@example.com from line \'Cc: One <one@example.com>, two@example.com\'\n'> 
          <'Dry-OK. Log says:\n'> <'Server: relay.example.com\n'> <'MAIL FROM:<from@example.com>\n'> <'RCPT TO:<to@example.com>\n'> 
          <'RCPT TO:<cc@example.com>\n'> <'RCPT TO:<author@example.com>\n'> <'RCPT TO:<one@example.com>\n'> <'RCPT TO:<two@example.com>\n'> 
          <'From: Example <from@example.com>\n'> <'To: to@example.com\n'> <'Cc: cc@example.com,\n'> <'\tA <author@example.com>,\n'> 
          <'\tOne <one@example.com>,\n'> <'\ttwo@example.com\n'> <'Subject: [PATCH 1/1] Second.\n'> <'Date: DATE-STRING\n'> 
          <'Message-Id: MESSAGE-ID-STRING\n'> <'X-Mailer: X-MAILER-STRING\n'> <'\n'> <'Result: OK\n'> <'EOF\n'>
        )
      }
    )
    (command.ShFunction
      name: replace_variable_fields
      body: 
        (BraceGroup
          children: [
            (C {<sed>} {<-e>} 
              {
                (DQ <'s/^'> <Id.Lit_BadBackslash '\\'> <'(Date:'> <Id.Lit_BadBackslash '\\'> <').*/'> 
                  <Id.Lit_BadBackslash '\\'> <'1 DATE-STRING/'>
                )
              } {<-e>} 
              {
                (DQ <'s/^'> <Id.Lit_BadBackslash '\\'> <'(Message-Id:'> <Id.Lit_BadBackslash '\\'> 
                  <').*/'> <Id.Lit_BadBackslash '\\'> <'1 MESSAGE-ID-STRING/'>
                )
              } {<-e>} 
              {
                (DQ <'s/^'> <Id.Lit_BadBackslash '\\'> <'(X-Mailer:'> <Id.Lit_BadBackslash '\\'> <').*/'> 
                  <Id.Lit_BadBackslash '\\'> <'1 X-MAILER-STRING/'>
                )
              }
            )
          ]
        )
    )
    (command.ShFunction
      name: test_suppression
      body: 
        (BraceGroup
          children: [
            (command.AndOr
              ops: [Id.Op_DAmp]
              children: [
                (command.Pipeline
                  children: [
                    (C {<git>} {<send-email>} {<--dry-run>} 
                      {<--suppress-cc> <Id.Lit_Equals '='> ($ Id.VSub_Number '$1')} 
                      {
                        (braced_var_sub
                          token: <Id.VSub_Number 2>
                          suffix_op: 
                            (suffix_op.Unary
                              tok: <Id.VTest_Plus '+'>
                              arg_word: {(DQ <'--suppress-cc='> ($ Id.VSub_Number '$2'))}
                            )
                        )
                      } {<--from> <Id.Lit_Equals '='> (DQ <'Example <from@example.com>'>)} 
                      {<--to> <Id.Lit_Equals '='> <to> <Id.Lit_Splice '@example'> <.com>} {<--smtp-server>} {<relay.example.com>} {($ Id.VSub_DollarName '$patches')}
                    )
                    (command.Simple
                      words: [{<replace_variable_fields>}]
                      redirects: [
                        (redir
                          op: <Id.Redir_Great '>'>
                          loc: (redir_loc.Fd fd:1)
                          arg: 
                            {<actual-suppress-> ($ Id.VSub_Number '$1') 
                              (braced_var_sub
                                token: <Id.VSub_Number 2>
                                suffix_op: 
                                  (suffix_op.Unary
                                    tok: <Id.VTest_Plus '+'>
                                    arg_word: {(DQ <-> ($ Id.VSub_Number '$2'))}
                                  )
                              )
                            }
                        )
                      ]
                      do_fork: T
                    )
                  ]
                  negated: F
                )
                (C {<test_cmp>} 
                  {<expected-suppress-> ($ Id.VSub_Number '$1') 
                    (braced_var_sub
                      token: <Id.VSub_Number 2>
                      suffix_op: 
                        (suffix_op.Unary
                          tok: <Id.VTest_Plus '+'>
                          arg_word: {(DQ <-> ($ Id.VSub_Number '$2'))}
                        )
                    )
                  } 
                  {<actual-suppress-> ($ Id.VSub_Number '$1') 
                    (braced_var_sub
                      token: <Id.VSub_Number 2>
                      suffix_op: 
                        (suffix_op.Unary
                          tok: <Id.VTest_Plus '+'>
                          arg_word: {(DQ <-> ($ Id.VSub_Number '$2'))}
                        )
                    )
                  }
                )
              ]
            )
          ]
        )
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'sendemail.cc set'>)} 
      {(SQ <'\n'> <'\tgit config sendemail.cc cc@example.com &&\n'> <'\ttest_suppression sob\n'>)}
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'setup expect'>)} 
      {
        (DQ <'\n'> <'cat >expected-suppress-sob <<'> <Id.Lit_BadBackslash '\\'> <'EOF\n'> 
          <'0001-Second.patch\n'> <'(mbox) Adding cc: A <author@example.com> from line \'From: A <author@example.com>\'\n'> 
          <
'(mbox) Adding cc: One <one@example.com> from line \'Cc: One <one@example.com>, two@example.com\'\n'
          > <'(mbox) Adding cc: two@example.com from line \'Cc: One <one@example.com>, two@example.com\'\n'> 
          <'Dry-OK. Log says:\n'> <'Server: relay.example.com\n'> <'MAIL FROM:<from@example.com>\n'> <'RCPT TO:<to@example.com>\n'> 
          <'RCPT TO:<author@example.com>\n'> <'RCPT TO:<one@example.com>\n'> <'RCPT TO:<two@example.com>\n'> <'From: Example <from@example.com>\n'> 
          <'To: to@example.com\n'> <'Cc: A <author@example.com>,\n'> <'\tOne <one@example.com>,\n'> <'\ttwo@example.com\n'> 
          <'Subject: [PATCH 1/1] Second.\n'> <'Date: DATE-STRING\n'> <'Message-Id: MESSAGE-ID-STRING\n'> <'X-Mailer: X-MAILER-STRING\n'> <'\n'> 
          <'Result: OK\n'> <'EOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'sendemail.cc unset'>)} 
      {(SQ <'\n'> <'\tgit config --unset sendemail.cc &&\n'> <'\ttest_suppression sob\n'>)}
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'setup expect'>)} 
      {
        (DQ <'\n'> <'cat >expected-suppress-cccmd <<'> <Id.Lit_BadBackslash '\\'> <'EOF\n'> 
          <'0001-Second.patch\n'> <'(mbox) Adding cc: A <author@example.com> from line \'From: A <author@example.com>\'\n'> 
          <
'(mbox) Adding cc: One <one@example.com> from line \'Cc: One <one@example.com>, two@example.com\'\n'
          > <'(mbox) Adding cc: two@example.com from line \'Cc: One <one@example.com>, two@example.com\'\n'> 
          <
'(body) Adding cc: C O Mitter <committer@example.com> from line \'Signed-off-by: C O Mitter <committer@example.com>\'\n'
          > <'Dry-OK. Log says:\n'> <'Server: relay.example.com\n'> <'MAIL FROM:<from@example.com>\n'> 
          <'RCPT TO:<to@example.com>\n'> <'RCPT TO:<author@example.com>\n'> <'RCPT TO:<one@example.com>\n'> <'RCPT TO:<two@example.com>\n'> 
          <'RCPT TO:<committer@example.com>\n'> <'From: Example <from@example.com>\n'> <'To: to@example.com\n'> <'Cc: A <author@example.com>,\n'> 
          <'\tOne <one@example.com>,\n'> <'\ttwo@example.com,\n'> <'\tC O Mitter <committer@example.com>\n'> <'Subject: [PATCH 1/1] Second.\n'> 
          <'Date: DATE-STRING\n'> <'Message-Id: MESSAGE-ID-STRING\n'> <'X-Mailer: X-MAILER-STRING\n'> <'\n'> <'Result: OK\n'> <'EOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <sendemail.cccmd>)} 
      {
        (SQ <'\n'> <'\twrite_script cccmd <<-\\EOF &&\n'> <'\techo cc-cmd@example.com\n'> <'\tEOF\n'> 
          <'\tgit config sendemail.cccmd ./cccmd &&\n'> <'\ttest_suppression cccmd\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'setup expect'>)} 
      {
        (SQ <'\n'> <'cat >expected-suppress-all <<\\EOF\n'> <'0001-Second.patch\n'> 
          <'Dry-OK. Log says:\n'> <'Server: relay.example.com\n'> <'MAIL FROM:<from@example.com>\n'> <'RCPT TO:<to@example.com>\n'> 
          <'From: Example <from@example.com>\n'> <'To: to@example.com\n'> <'Subject: [PATCH 1/1] Second.\n'> <'Date: DATE-STRING\n'> 
          <'Message-Id: MESSAGE-ID-STRING\n'> <'X-Mailer: X-MAILER-STRING\n'> <'\n'> <'Result: OK\n'> <'EOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'--suppress-cc=all'>)} 
      {(SQ <'\n'> <'\ttest_suppression all\n'>)}
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'setup expect'>)} 
      {
        (DQ <'\n'> <'cat >expected-suppress-body <<'> <Id.Lit_BadBackslash '\\'> <'EOF\n'> 
          <'0001-Second.patch\n'> <'(mbox) Adding cc: A <author@example.com> from line \'From: A <author@example.com>\'\n'> 
          <
'(mbox) Adding cc: One <one@example.com> from line \'Cc: One <one@example.com>, two@example.com\'\n'
          > <'(mbox) Adding cc: two@example.com from line \'Cc: One <one@example.com>, two@example.com\'\n'> 
          <'(cc-cmd) Adding cc: cc-cmd@example.com from: \'./cccmd\'\n'> <'Dry-OK. Log says:\n'> <'Server: relay.example.com\n'> <'MAIL FROM:<from@example.com>\n'> 
          <'RCPT TO:<to@example.com>\n'> <'RCPT TO:<author@example.com>\n'> <'RCPT TO:<one@example.com>\n'> <'RCPT TO:<two@example.com>\n'> 
          <'RCPT TO:<cc-cmd@example.com>\n'> <'From: Example <from@example.com>\n'> <'To: to@example.com\n'> <'Cc: A <author@example.com>,\n'> 
          <'\tOne <one@example.com>,\n'> <'\ttwo@example.com,\n'> <'\tcc-cmd@example.com\n'> <'Subject: [PATCH 1/1] Second.\n'> 
          <'Date: DATE-STRING\n'> <'Message-Id: MESSAGE-ID-STRING\n'> <'X-Mailer: X-MAILER-STRING\n'> <'\n'> <'Result: OK\n'> <'EOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'--suppress-cc=body'>)} 
      {(SQ <'\n'> <'\ttest_suppression body\n'>)}
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'setup expect'>)} 
      {
        (DQ <'\n'> <'cat >expected-suppress-body-cccmd <<'> <Id.Lit_BadBackslash '\\'> <'EOF\n'> 
          <'0001-Second.patch\n'> <'(mbox) Adding cc: A <author@example.com> from line \'From: A <author@example.com>\'\n'> 
          <
'(mbox) Adding cc: One <one@example.com> from line \'Cc: One <one@example.com>, two@example.com\'\n'
          > <'(mbox) Adding cc: two@example.com from line \'Cc: One <one@example.com>, two@example.com\'\n'> 
          <'Dry-OK. Log says:\n'> <'Server: relay.example.com\n'> <'MAIL FROM:<from@example.com>\n'> <'RCPT TO:<to@example.com>\n'> 
          <'RCPT TO:<author@example.com>\n'> <'RCPT TO:<one@example.com>\n'> <'RCPT TO:<two@example.com>\n'> <'From: Example <from@example.com>\n'> 
          <'To: to@example.com\n'> <'Cc: A <author@example.com>,\n'> <'\tOne <one@example.com>,\n'> <'\ttwo@example.com\n'> 
          <'Subject: [PATCH 1/1] Second.\n'> <'Date: DATE-STRING\n'> <'Message-Id: MESSAGE-ID-STRING\n'> <'X-Mailer: X-MAILER-STRING\n'> <'\n'> 
          <'Result: OK\n'> <'EOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'--suppress-cc=body --suppress-cc=cccmd'>)} {(SQ <'\n'> <'\ttest_suppression body cccmd\n'>)}
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'setup expect'>)} 
      {
        (DQ <'\n'> <'cat >expected-suppress-sob <<'> <Id.Lit_BadBackslash '\\'> <'EOF\n'> 
          <'0001-Second.patch\n'> <'(mbox) Adding cc: A <author@example.com> from line \'From: A <author@example.com>\'\n'> 
          <
'(mbox) Adding cc: One <one@example.com> from line \'Cc: One <one@example.com>, two@example.com\'\n'
          > <'(mbox) Adding cc: two@example.com from line \'Cc: One <one@example.com>, two@example.com\'\n'> 
          <'Dry-OK. Log says:\n'> <'Server: relay.example.com\n'> <'MAIL FROM:<from@example.com>\n'> <'RCPT TO:<to@example.com>\n'> 
          <'RCPT TO:<author@example.com>\n'> <'RCPT TO:<one@example.com>\n'> <'RCPT TO:<two@example.com>\n'> <'From: Example <from@example.com>\n'> 
          <'To: to@example.com\n'> <'Cc: A <author@example.com>,\n'> <'\tOne <one@example.com>,\n'> <'\ttwo@example.com\n'> 
          <'Subject: [PATCH 1/1] Second.\n'> <'Date: DATE-STRING\n'> <'Message-Id: MESSAGE-ID-STRING\n'> <'X-Mailer: X-MAILER-STRING\n'> <'\n'> 
          <'Result: OK\n'> <'EOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'--suppress-cc=sob'>)} 
      {
        (SQ <'\n'> <'\ttest_might_fail git config --unset sendemail.cccmd &&\n'> 
          <'\ttest_suppression sob\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'setup expect'>)} 
      {
        (DQ <'\n'> <'cat >expected-suppress-bodycc <<'> <Id.Lit_BadBackslash '\\'> <'EOF\n'> 
          <'0001-Second.patch\n'> <'(mbox) Adding cc: A <author@example.com> from line \'From: A <author@example.com>\'\n'> 
          <
'(mbox) Adding cc: One <one@example.com> from line \'Cc: One <one@example.com>, two@example.com\'\n'
          > <'(mbox) Adding cc: two@example.com from line \'Cc: One <one@example.com>, two@example.com\'\n'> 
          <
'(body) Adding cc: C O Mitter <committer@example.com> from line \'Signed-off-by: C O Mitter <committer@example.com>\'\n'
          > <'Dry-OK. Log says:\n'> <'Server: relay.example.com\n'> <'MAIL FROM:<from@example.com>\n'> 
          <'RCPT TO:<to@example.com>\n'> <'RCPT TO:<author@example.com>\n'> <'RCPT TO:<one@example.com>\n'> <'RCPT TO:<two@example.com>\n'> 
          <'RCPT TO:<committer@example.com>\n'> <'From: Example <from@example.com>\n'> <'To: to@example.com\n'> <'Cc: A <author@example.com>,\n'> 
          <'\tOne <one@example.com>,\n'> <'\ttwo@example.com,\n'> <'\tC O Mitter <committer@example.com>\n'> <'Subject: [PATCH 1/1] Second.\n'> 
          <'Date: DATE-STRING\n'> <'Message-Id: MESSAGE-ID-STRING\n'> <'X-Mailer: X-MAILER-STRING\n'> <'\n'> <'Result: OK\n'> <'EOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'--suppress-cc=bodycc'>)} 
      {(SQ <'\n'> <'\ttest_suppression bodycc\n'>)}
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'setup expect'>)} 
      {
        (DQ <'\n'> <'cat >expected-suppress-cc <<'> <Id.Lit_BadBackslash '\\'> <'EOF\n'> 
          <'0001-Second.patch\n'> <'(mbox) Adding cc: A <author@example.com> from line \'From: A <author@example.com>\'\n'> 
          <
'(body) Adding cc: C O Mitter <committer@example.com> from line \'Signed-off-by: C O Mitter <committer@example.com>\'\n'
          > <'Dry-OK. Log says:\n'> <'Server: relay.example.com\n'> <'MAIL FROM:<from@example.com>\n'> 
          <'RCPT TO:<to@example.com>\n'> <'RCPT TO:<author@example.com>\n'> <'RCPT TO:<committer@example.com>\n'> 
          <'From: Example <from@example.com>\n'> <'To: to@example.com\n'> <'Cc: A <author@example.com>,\n'> <'\tC O Mitter <committer@example.com>\n'> 
          <'Subject: [PATCH 1/1] Second.\n'> <'Date: DATE-STRING\n'> <'Message-Id: MESSAGE-ID-STRING\n'> <'X-Mailer: X-MAILER-STRING\n'> <'\n'> 
          <'Result: OK\n'> <'EOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'--suppress-cc=cc'>)} 
      {(SQ <'\n'> <'\ttest_suppression cc\n'>)}
    )
    (command.ShFunction
      name: test_confirm
      body: 
        (BraceGroup
          children: [
            (command.AndOr
              ops: [Id.Op_DAmp]
              children: [
                (command.Pipeline
                  children: [
                    (C {<echo>} {<y>})
                    (command.Simple
                      words: [
                        {<git>}
                        {<send-email>}
                        {<--from> <Id.Lit_Equals '='> (DQ <'Example <nobody@example.com>'>)}
                        {<--to> <Id.Lit_Equals '='> <nobody> <Id.Lit_Splice '@example'> <.com>}
                        {<--smtp-server> <Id.Lit_Equals '='> 
                          (DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})) 
                            <'/fake.sendmail'>
                          )
                        }
                        {($ Id.VSub_At '$@')}
                        {($ Id.VSub_DollarName '$patches')}
                      ]
                      redirects: [
                        (redir
                          op: <Id.Redir_Great '>'>
                          loc: (redir_loc.Fd fd:1)
                          arg: {<stdout>}
                        )
                      ]
                      more_env: [(env_pair name:GIT_SEND_EMAIL_NOTTY val:{<1>} spids:[2087])]
                      do_fork: T
                    )
                  ]
                  negated: F
                )
                (C {<grep>} {(DQ <'Send this email'>)} {<stdout>})
              ]
            )
          ]
        )
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'--confirm=always'>)} 
      {(SQ <'\n'> <'\ttest_confirm --confirm=always --suppress-cc=all\n'>)}
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'--confirm=auto'>)} 
      {(SQ <'\n'> <'\ttest_confirm --confirm=auto\n'>)}
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'--confirm=cc'>)} 
      {(SQ <'\n'> <'\ttest_confirm --confirm=cc\n'>)}
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'--confirm=compose'>)} 
      {(SQ <'\n'> <'\ttest_confirm --confirm=compose --compose\n'>)}
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'confirm by default (due to cc)'>)} 
      {
        (SQ <'\n'> <'\ttest_when_finished git config sendemail.confirm never &&\n'> 
          <'\tgit config --unset sendemail.confirm &&\n'> <'\ttest_confirm\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'confirm by default (due to --compose)'>)} 
      {
        (SQ <'\n'> <'\ttest_when_finished git config sendemail.confirm never &&\n'> 
          <'\tgit config --unset sendemail.confirm &&\n'> <'\ttest_confirm --suppress-cc=all --compose\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'confirm detects EOF (inform assumes y)'>)} 
      {
        (SQ <'\n'> <'\ttest_when_finished git config sendemail.confirm never &&\n'> 
          <'\tgit config --unset sendemail.confirm &&\n'> <'\trm -fr outdir &&\n'> <'\tgit format-patch -2 -o outdir &&\n'> <'\tGIT_SEND_EMAIL_NOTTY=1 \\\n'> 
          <'\t\tgit send-email \\\n'> <'\t\t\t--from="Example <nobody@example.com>" \\\n'> <'\t\t\t--to=nobody@example.com \\\n'> 
          <'\t\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\t\toutdir/*.patch </dev/null\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'confirm detects EOF (auto causes failure)'>)} 
      {
        (SQ <'\n'> <'\ttest_when_finished git config sendemail.confirm never &&\n'> 
          <'\tgit config sendemail.confirm auto &&\n'> <'\tGIT_SEND_EMAIL_NOTTY=1 &&\n'> <'\texport GIT_SEND_EMAIL_NOTTY &&\n'> 
          <'\t\ttest_must_fail git send-email \\\n'> <'\t\t\t--from="Example <nobody@example.com>" \\\n'> <'\t\t\t--to=nobody@example.com \\\n'> 
          <'\t\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\t\t$patches </dev/null\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'confirm does not loop forever'>)} 
      {
        (SQ <'\n'> <'\ttest_when_finished git config sendemail.confirm never &&\n'> 
          <'\tgit config sendemail.confirm auto &&\n'> <'\tGIT_SEND_EMAIL_NOTTY=1 &&\n'> <'\texport GIT_SEND_EMAIL_NOTTY &&\n'> 
          <'\t\tyes "bogus" | test_must_fail git send-email \\\n'> <'\t\t\t--from="Example <nobody@example.com>" \\\n'> <'\t\t\t--to=nobody@example.com \\\n'> 
          <'\t\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\t\t$patches\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'utf8 Cc is rfc2047 encoded'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\trm -fr outdir &&\n'> 
          <'\tgit format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" &&\n'> <'\tgit send-email \\\n'> <'\t--from="Example <nobody@example.com>" \\\n'> 
          <'\t--to=nobody@example.com \\\n'> <'\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\toutdir/*.patch &&\n'> <'\tgrep "^\t" msgtxt1 |\n'> 
          <'\tgrep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>"\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'--compose adds MIME for utf8 body'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\twrite_script fake-editor-utf8 <<-\\EOF &&\n'> 
          <'\techo "utf8 body: àéìöú" >>"$1"\n'> <'\tEOF\n'> <'\tGIT_EDITOR="\\"$(pwd)/fake-editor-utf8\\"" \\\n'> <'\tgit send-email \\\n'> 
          <'\t\t--compose --subject foo \\\n'> <'\t\t--from="Example <nobody@example.com>" \\\n'> <'\t\t--to=nobody@example.com \\\n'> 
          <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\t$patches &&\n'> <'\tgrep "^utf8 body" msgtxt1 &&\n'> 
          <'\tgrep "^Content-Type: text/plain; charset=UTF-8" msgtxt1\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'--compose respects user mime type'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> 
          <'\twrite_script fake-editor-utf8-mime <<-\\EOF &&\n'> <'\tcat >"$1" <<-\\EOM\n'> <'\tMIME-Version: 1.0\n'> 
          <'\tContent-Type: text/plain; charset=iso-8859-1\n'> <'\tContent-Transfer-Encoding: 8bit\n'> <'\tSubject: foo\n'> <'\n'> <'\tutf8 body: àéìöú\n'> 
          <'\tEOM\n'> <'\tEOF\n'> <'\tGIT_EDITOR="\\"$(pwd)/fake-editor-utf8-mime\\"" \\\n'> <'\tgit send-email \\\n'> 
          <'\t\t--compose --subject foo \\\n'> <'\t\t--from="Example <nobody@example.com>" \\\n'> <'\t\t--to=nobody@example.com \\\n'> 
          <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\t$patches &&\n'> <'\tgrep "^utf8 body" msgtxt1 &&\n'> 
          <'\tgrep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 &&\n'> <'\t! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'--compose adds MIME for utf8 subject'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\tGIT_EDITOR="\\"$(pwd)/fake-editor\\"" \\\n'> 
          <'\tgit send-email \\\n'> <'\t\t--compose --subject utf8-sübjëct \\\n'> <'\t\t--from="Example <nobody@example.com>" \\\n'> 
          <'\t\t--to=nobody@example.com \\\n'> <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\t$patches &&\n'> 
          <'\tgrep "^fake edit" msgtxt1 &&\n'> <'\tgrep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'utf8 author is correctly passed on'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\ttest_commit weird_author &&\n'> 
          <'\ttest_when_finished "git reset --hard HEAD^" &&\n'> <'\tgit commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" &&\n'> 
          <'\tgit format-patch --stdout -1 >funny_name.patch &&\n'> <'\tgit send-email --from="Example <nobody@example.com>" \\\n'> <'\t\t--to=nobody@example.com \\\n'> 
          <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\tfunny_name.patch &&\n'> <'\tgrep "^From: Füñný Nâmé <odd_?=mail@example.com>" msgtxt1\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'utf8 sender is not duplicated'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\ttest_commit weird_sender &&\n'> 
          <'\ttest_when_finished "git reset --hard HEAD^" &&\n'> <'\tgit commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" &&\n'> 
          <'\tgit format-patch --stdout -1 >funny_name.patch &&\n'> <'\tgit send-email --from="Füñný Nâmé <odd_?=mail@example.com>" \\\n'> 
          <'\t\t--to=nobody@example.com \\\n'> <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\tfunny_name.patch &&\n'> 
          <'\tgrep "^From: " msgtxt1 >msgfrom &&\n'> <'\ttest_line_count = 1 msgfrom\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'sendemail.composeencoding works'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> 
          <'\tgit config sendemail.composeencoding iso-8859-1 &&\n'> <'\twrite_script fake-editor-utf8 <<-\\EOF &&\n'> <'\techo "utf8 body: àéìöú" >>"$1"\n'> 
          <'\tEOF\n'> <'\tGIT_EDITOR="\\"$(pwd)/fake-editor-utf8\\"" \\\n'> <'\tgit send-email \\\n'> 
          <'\t\t--compose --subject foo \\\n'> <'\t\t--from="Example <nobody@example.com>" \\\n'> <'\t\t--to=nobody@example.com \\\n'> 
          <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\t$patches &&\n'> <'\tgrep "^utf8 body" msgtxt1 &&\n'> 
          <'\tgrep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'--compose-encoding works'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\twrite_script fake-editor-utf8 <<-\\EOF &&\n'> 
          <'\techo "utf8 body: àéìöú" >>"$1"\n'> <'\tEOF\n'> <'\tGIT_EDITOR="\\"$(pwd)/fake-editor-utf8\\"" \\\n'> <'\tgit send-email \\\n'> 
          <'\t\t--compose-encoding iso-8859-1 \\\n'> <'\t\t--compose --subject foo \\\n'> <'\t\t--from="Example <nobody@example.com>" \\\n'> 
          <'\t\t--to=nobody@example.com \\\n'> <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\t$patches &&\n'> 
          <'\tgrep "^utf8 body" msgtxt1 &&\n'> <'\tgrep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'--compose-encoding overrides sendemail.composeencoding'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> 
          <'\tgit config sendemail.composeencoding iso-8859-1 &&\n'> <'\twrite_script fake-editor-utf8 <<-\\EOF &&\n'> <'\techo "utf8 body: àéìöú" >>"$1"\n'> 
          <'\tEOF\n'> <'\tGIT_EDITOR="\\"$(pwd)/fake-editor-utf8\\"" \\\n'> <'\tgit send-email \\\n'> 
          <'\t\t--compose-encoding iso-8859-2 \\\n'> <'\t\t--compose --subject foo \\\n'> <'\t\t--from="Example <nobody@example.com>" \\\n'> 
          <'\t\t--to=nobody@example.com \\\n'> <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\t$patches &&\n'> 
          <'\tgrep "^utf8 body" msgtxt1 &&\n'> <'\tgrep "^Content-Type: text/plain; charset=iso-8859-2" msgtxt1\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'--compose-encoding adds correct MIME for subject'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\tGIT_EDITOR="\\"$(pwd)/fake-editor\\"" \\\n'> 
          <'\tgit send-email \\\n'> <'\t\t--compose-encoding iso-8859-2 \\\n'> <'\t\t--compose --subject utf8-sübjëct \\\n'> 
          <'\t\t--from="Example <nobody@example.com>" \\\n'> <'\t\t--to=nobody@example.com \\\n'> <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> 
          <'\t\t$patches &&\n'> <'\tgrep "^fake edit" msgtxt1 &&\n'> 
          <'\tgrep "^Subject: =?iso-8859-2?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'detects ambiguous reference/file conflict'>)} 
      {
        (SQ <'\n'> <'\techo master >master &&\n'> <'\tgit add master &&\n'> 
          <'\tgit commit -m"add master" &&\n'> <'\ttest_must_fail git send-email --dry-run master 2>errors &&\n'> <'\tgrep disambiguate errors\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'feed two files'>)} 
      {
        (SQ <'\n'> <'\trm -fr outdir &&\n'> <'\tgit format-patch -2 -o outdir &&\n'> 
          <'\tgit send-email \\\n'> <'\t\t--dry-run \\\n'> <'\t\t--from="Example <nobody@example.com>" \\\n'> 
          <'\t\t--to=nobody@example.com \\\n'> <'\t\toutdir/000?-*.patch 2>errors >out &&\n'> <'\tgrep "^Subject: " out >subjects &&\n'> 
          <'\ttest "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." &&\n'> <'\ttest "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master"\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'in-reply-to but no threading'>)} 
      {
        (SQ <'\n'> <'\tgit send-email \\\n'> <'\t\t--dry-run \\\n'> 
          <'\t\t--from="Example <nobody@example.com>" \\\n'> <'\t\t--to=nobody@example.com \\\n'> <'\t\t--in-reply-to="<in-reply-id@example.com>" \\\n'> 
          <'\t\t--no-thread \\\n'> <'\t\t$patches |\n'> <'\tgrep "In-Reply-To: <in-reply-id@example.com>"\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'no in-reply-to and no threading'>)} 
      {
        (SQ <'\n'> <'\tgit send-email \\\n'> <'\t\t--dry-run \\\n'> 
          <'\t\t--from="Example <nobody@example.com>" \\\n'> <'\t\t--to=nobody@example.com \\\n'> <'\t\t--no-thread \\\n'> <'\t\t$patches $patches >stdout &&\n'> 
          <'\t! grep "In-Reply-To: " stdout\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'threading but no chain-reply-to'>)} 
      {
        (SQ <'\n'> <'\tgit send-email \\\n'> <'\t\t--dry-run \\\n'> 
          <'\t\t--from="Example <nobody@example.com>" \\\n'> <'\t\t--to=nobody@example.com \\\n'> <'\t\t--thread \\\n'> <'\t\t--no-chain-reply-to \\\n'> 
          <'\t\t$patches $patches >stdout &&\n'> <'\tgrep "In-Reply-To: " stdout\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'sendemail.to works'>)} 
      {
        (SQ <'\n'> <'\tgit config --replace-all sendemail.to "Somebody <somebody@ex.com>" &&\n'> 
          <'\tgit send-email \\\n'> <'\t\t--dry-run \\\n'> <'\t\t--from="Example <nobody@example.com>" \\\n'> 
          <'\t\t$patches $patches >stdout &&\n'> <'\tgrep "To: Somebody <somebody@ex.com>" stdout\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'--no-to overrides sendemail.to'>)} 
      {
        (SQ <'\n'> <'\tgit send-email \\\n'> <'\t\t--dry-run \\\n'> 
          <'\t\t--from="Example <nobody@example.com>" \\\n'> <'\t\t--no-to \\\n'> <'\t\t--to=nobody@example.com \\\n'> <'\t\t$patches $patches >stdout &&\n'> 
          <'\tgrep "To: nobody@example.com" stdout &&\n'> <'\t! grep "To: Somebody <somebody@ex.com>" stdout\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'sendemail.cc works'>)} 
      {
        (SQ <'\n'> <'\tgit config --replace-all sendemail.cc "Somebody <somebody@ex.com>" &&\n'> 
          <'\tgit send-email \\\n'> <'\t\t--dry-run \\\n'> <'\t\t--from="Example <nobody@example.com>" \\\n'> 
          <'\t\t--to=nobody@example.com \\\n'> <'\t\t$patches $patches >stdout &&\n'> <'\tgrep "Cc: Somebody <somebody@ex.com>" stdout\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'--no-cc overrides sendemail.cc'>)} 
      {
        (SQ <'\n'> <'\tgit send-email \\\n'> <'\t\t--dry-run \\\n'> 
          <'\t\t--from="Example <nobody@example.com>" \\\n'> <'\t\t--no-cc \\\n'> <'\t\t--cc=bodies@example.com \\\n'> <'\t\t--to=nobody@example.com \\\n'> 
          <'\t\t$patches $patches >stdout &&\n'> <'\tgrep "Cc: bodies@example.com" stdout &&\n'> <'\t! grep "Cc: Somebody <somebody@ex.com>" stdout\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'sendemail.bcc works'>)} 
      {
        (SQ <'\n'> <'\tgit config --replace-all sendemail.bcc "Other <other@ex.com>" &&\n'> 
          <'\tgit send-email \\\n'> <'\t\t--dry-run \\\n'> <'\t\t--from="Example <nobody@example.com>" \\\n'> 
          <'\t\t--to=nobody@example.com \\\n'> <'\t\t--smtp-server relay.example.com \\\n'> <'\t\t$patches $patches >stdout &&\n'> 
          <'\tgrep "RCPT TO:<other@ex.com>" stdout\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'--no-bcc overrides sendemail.bcc'>)} 
      {
        (SQ <'\n'> <'\tgit send-email \\\n'> <'\t\t--dry-run \\\n'> 
          <'\t\t--from="Example <nobody@example.com>" \\\n'> <'\t\t--no-bcc \\\n'> <'\t\t--bcc=bodies@example.com \\\n'> <'\t\t--to=nobody@example.com \\\n'> 
          <'\t\t--smtp-server relay.example.com \\\n'> <'\t\t$patches $patches >stdout &&\n'> <'\tgrep "RCPT TO:<bodies@example.com>" stdout &&\n'> 
          <'\t! grep "RCPT TO:<other@ex.com>" stdout\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'patches To headers are used by default'>)} 
      {
        (SQ <'\n'> <'\tpatch=$(git format-patch -1 --to="bodies@example.com") &&\n'> 
          <'\ttest_when_finished "rm $patch" &&\n'> <'\tgit send-email \\\n'> <'\t\t--dry-run \\\n'> <'\t\t--from="Example <nobody@example.com>" \\\n'> 
          <'\t\t--smtp-server relay.example.com \\\n'> <'\t\t$patch >stdout &&\n'> <'\tgrep "RCPT TO:<bodies@example.com>" stdout\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'patches To headers are appended to'>)} 
      {
        (SQ <'\n'> <'\tpatch=$(git format-patch -1 --to="bodies@example.com") &&\n'> 
          <'\ttest_when_finished "rm $patch" &&\n'> <'\tgit send-email \\\n'> <'\t\t--dry-run \\\n'> <'\t\t--from="Example <nobody@example.com>" \\\n'> 
          <'\t\t--to=nobody@example.com \\\n'> <'\t\t--smtp-server relay.example.com \\\n'> <'\t\t$patch >stdout &&\n'> 
          <'\tgrep "RCPT TO:<bodies@example.com>" stdout &&\n'> <'\tgrep "RCPT TO:<nobody@example.com>" stdout\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'To headers from files reset each patch'>)} 
      {
        (SQ <'\n'> <'\tpatch1=$(git format-patch -1 --to="bodies@example.com") &&\n'> 
          <'\tpatch2=$(git format-patch -1 --to="other@example.com" HEAD~) &&\n'> <'\ttest_when_finished "rm $patch1 && rm $patch2" &&\n'> <'\tgit send-email \\\n'> 
          <'\t\t--dry-run \\\n'> <'\t\t--from="Example <nobody@example.com>" \\\n'> <'\t\t--to="nobody@example.com" \\\n'> 
          <'\t\t--smtp-server relay.example.com \\\n'> <'\t\t$patch1 $patch2 >stdout &&\n'> 
          <'\ttest $(grep -c "RCPT TO:<bodies@example.com>" stdout) = 1 &&\n'> <'\ttest $(grep -c "RCPT TO:<nobody@example.com>" stdout) = 2 &&\n'> 
          <'\ttest $(grep -c "RCPT TO:<other@example.com>" stdout) = 1\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'setup expect'>)} 
      {
        (SQ <'\n'> <'cat >email-using-8bit <<\\EOF\n'> 
          <'From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001\n'> <'Message-Id: <bogus-message-id@example.com>\n'> <'From: author@example.com\n'> 
          <'Date: Sat, 12 Jun 2010 15:53:58 +0200\n'> <'Subject: subject goes here\n'> <'\n'> <'Dieser deutsche Text enthält einen Umlaut!\n'> <'EOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'setup expect'>)} 
      {(SQ <'\n'> <'\techo "Subject: subject goes here" >expected\n'>)}
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'ASCII subject is not RFC2047 quoted'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\techo bogus |\n'> 
          <'\tgit send-email --from=author@example.com --to=nobody@example.com \\\n'> <'\t\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\t\t--8bit-encoding=UTF-8 \\\n'> 
          <'\t\t\temail-using-8bit >stdout &&\n'> <'\tgrep "Subject" msgtxt1 >actual &&\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'setup expect'>)} 
      {
        (SQ <'\n'> <'\tcat >content-type-decl <<-\\EOF\n'> <'\tMIME-Version: 1.0\n'> 
          <'\tContent-Type: text/plain; charset=UTF-8\n'> <'\tContent-Transfer-Encoding: 8bit\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'asks about and fixes 8bit encodings'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\techo |\n'> 
          <'\tgit send-email --from=author@example.com --to=nobody@example.com \\\n'> <'\t\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\t\temail-using-8bit >stdout &&\n'> 
          <'\tgrep "do not declare a Content-Transfer-Encoding" stdout &&\n'> <'\tgrep email-using-8bit stdout &&\n'> <'\tgrep "Which 8bit encoding" stdout &&\n'> 
          <'\tegrep "Content|MIME" msgtxt1 >actual &&\n'> <'\ttest_cmp actual content-type-decl\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'sendemail.8bitEncoding works'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> 
          <'\tgit config sendemail.assume8bitEncoding UTF-8 &&\n'> <'\techo bogus |\n'> <'\tgit send-email --from=author@example.com --to=nobody@example.com \\\n'> 
          <'\t\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\t\temail-using-8bit >stdout &&\n'> <'\tegrep "Content|MIME" msgtxt1 >actual &&\n'> 
          <'\ttest_cmp actual content-type-decl\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'--8bit-encoding overrides sendemail.8bitEncoding'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> 
          <'\tgit config sendemail.assume8bitEncoding "bogus too" &&\n'> <'\techo bogus |\n'> <'\tgit send-email --from=author@example.com --to=nobody@example.com \\\n'> 
          <'\t\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\t\t--8bit-encoding=UTF-8 \\\n'> <'\t\t\temail-using-8bit >stdout &&\n'> 
          <'\tegrep "Content|MIME" msgtxt1 >actual &&\n'> <'\ttest_cmp actual content-type-decl\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'setup expect'>)} 
      {
        (SQ <'\n'> <'\tcat >email-using-8bit <<-\\EOF\n'> 
          <'\tFrom fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001\n'> <'\tMessage-Id: <bogus-message-id@example.com>\n'> <'\tFrom: author@example.com\n'> 
          <'\tDate: Sat, 12 Jun 2010 15:53:58 +0200\n'> <'\tSubject: Dieser Betreff enthält auch einen Umlaut!\n'> <'\n'> <'\tNothing to see here.\n'> 
          <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'setup expect'>)} 
      {
        (SQ <'\n'> <'\tcat >expected <<-\\EOF\n'> 
          <'\tSubject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?=\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'--8bit-encoding also treats subject'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\techo bogus |\n'> 
          <'\tgit send-email --from=author@example.com --to=nobody@example.com \\\n'> <'\t\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\t\t--8bit-encoding=UTF-8 \\\n'> 
          <'\t\t\temail-using-8bit >stdout &&\n'> <'\tgrep "Subject" msgtxt1 >actual &&\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'setup expect'>)} 
      {
        (SQ <'\n'> <'\tcat >email-using-8bit <<-\\EOF\n'> 
          <'\tFrom fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001\n'> <'\tMessage-Id: <bogus-message-id@example.com>\n'> <'\tFrom: A U Thor <author@example.com>\n'> 
          <'\tDate: Sat, 12 Jun 2010 15:53:58 +0200\n'> <'\tContent-Type: text/plain; charset=UTF-8\n'> <'\tSubject: Nothing to see here.\n'> <'\n'> 
          <'\tDieser Betreff enthält auch einen Umlaut!\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'sendemail.transferencoding=7bit fails on 8bit data'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\tgit config sendemail.transferEncoding 7bit &&\n'> 
          <'\ttest_must_fail git send-email \\\n'> <'\t\t--transfer-encoding=7bit \\\n'> <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> 
          <'\t\temail-using-8bit \\\n'> <'\t\t2>errors >out &&\n'> <'\tgrep "cannot send message as 7bit" errors &&\n'> 
          <'\ttest -z "$(ls msgtxt*)"\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'--transfer-encoding overrides sendemail.transferEncoding'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\tgit config sendemail.transferEncoding 8bit &&\n'> 
          <'\ttest_must_fail git send-email \\\n'> <'\t\t--transfer-encoding=7bit \\\n'> <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> 
          <'\t\temail-using-8bit \\\n'> <'\t\t2>errors >out &&\n'> <'\tgrep "cannot send message as 7bit" errors &&\n'> 
          <'\ttest -z "$(ls msgtxt*)"\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'sendemail.transferencoding=8bit'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\tgit send-email \\\n'> 
          <'\t\t--transfer-encoding=8bit \\\n'> <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\temail-using-8bit \\\n'> 
          <'\t\t2>errors >out &&\n'> <'\tsed '>
        ) <1> <Id.Lit_Comma ','> <'/'> <Id.Lit_Other '^'> <Id.Lit_Dollar '$'> <'/d'> 
        (SQ <' msgtxt1 >actual &&\n'> <'\tsed '>) <1> <Id.Lit_Comma ','> <'/'> <Id.Lit_Other '^'> <Id.Lit_Dollar '$'> <'/d'> 
        (SQ <' email-using-8bit >expected &&\n'> <'\ttest_cmp expected actual\n'>)
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'setup expect'>)} 
      {
        (SQ <'\n'> <'\tcat >expected <<-\\EOF\n'> 
          <'\tDieser Betreff enth=C3=A4lt auch einen Umlaut!\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'8-bit and sendemail.transferencoding=quoted-printable'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\tgit send-email \\\n'> 
          <'\t\t--transfer-encoding=quoted-printable \\\n'> <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\temail-using-8bit \\\n'> 
          <'\t\t2>errors >out &&\n'> <'\tsed '>
        ) <1> <Id.Lit_Comma ','> <'/'> <Id.Lit_Other '^'> <Id.Lit_Dollar '$'> <'/d'> 
        (SQ <' msgtxt1 >actual &&\n'> <'\ttest_cmp expected actual\n'>)
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'setup expect'>)} 
      {
        (SQ <'\n'> <'\tcat >expected <<-\\EOF\n'> 
          <'\tRGllc2VyIEJldHJlZmYgZW50aMOkbHQgYXVjaCBlaW5lbiBVbWxhdXQhCg==\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'8-bit and sendemail.transferencoding=base64'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\tgit send-email \\\n'> 
          <'\t\t--transfer-encoding=base64 \\\n'> <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\temail-using-8bit \\\n'> 
          <'\t\t2>errors >out &&\n'> <'\tsed '>
        ) <1> <Id.Lit_Comma ','> <'/'> <Id.Lit_Other '^'> <Id.Lit_Dollar '$'> <'/d'> 
        (SQ <' msgtxt1 >actual &&\n'> <'\ttest_cmp expected actual\n'>)
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'setup expect'>)} 
      {
        (SQ <'\n'> <'\tcat >email-using-qp <<-\\EOF\n'> 
          <'\tFrom fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001\n'> <'\tMessage-Id: <bogus-message-id@example.com>\n'> <'\tFrom: A U Thor <author@example.com>\n'> 
          <'\tDate: Sat, 12 Jun 2010 15:53:58 +0200\n'> <'\tMIME-Version: 1.0\n'> <'\tContent-Transfer-Encoding: quoted-printable\n'> 
          <'\tContent-Type: text/plain; charset=UTF-8\n'> <'\tSubject: Nothing to see here.\n'> <'\n'> <'\tDieser Betreff enth=C3=A4lt auch einen Umlaut!\n'> 
          <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'convert from quoted-printable to base64'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\tgit send-email \\\n'> 
          <'\t\t--transfer-encoding=base64 \\\n'> <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\temail-using-qp \\\n'> 
          <'\t\t2>errors >out &&\n'> <'\tsed '>
        ) <1> <Id.Lit_Comma ','> <'/'> <Id.Lit_Other '^'> <Id.Lit_Dollar '$'> <'/d'> 
        (SQ <' msgtxt1 >actual &&\n'> <'\ttest_cmp expected actual\n'>)
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'setup expect'>)} 
      {
        (DQ <'\n'> <'tr -d \''> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\\\'>) 
          <'015\' | tr \'%\' \''> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\\\'>) <'015\' >email-using-crlf <<EOF\n'> 
          <'From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001\n'> <'Message-Id: <bogus-message-id@example.com>\n'> <'From: A U Thor <author@example.com>\n'> 
          <'Date: Sat, 12 Jun 2010 15:53:58 +0200\n'> <'Content-Type: text/plain; charset=UTF-8\n'> <'Subject: Nothing to see here.\n'> <'\n'> 
          <'Look, I have a CRLF and an = sign!%\n'> <'EOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'setup expect'>)} 
      {
        (SQ <'\n'> <'\tcat >expected <<-\\EOF\n'> <'\tLook, I have a CRLF and an =3D sign!=0D\n'> 
          <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'CRLF and sendemail.transferencoding=quoted-printable'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\tgit send-email \\\n'> 
          <'\t\t--transfer-encoding=quoted-printable \\\n'> <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\temail-using-crlf \\\n'> 
          <'\t\t2>errors >out &&\n'> <'\tsed '>
        ) <1> <Id.Lit_Comma ','> <'/'> <Id.Lit_Other '^'> <Id.Lit_Dollar '$'> <'/d'> 
        (SQ <' msgtxt1 >actual &&\n'> <'\ttest_cmp expected actual\n'>)
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'setup expect'>)} 
      {
        (SQ <'\n'> <'\tcat >expected <<-\\EOF\n'> 
          <'\tTG9vaywgSSBoYXZlIGEgQ1JMRiBhbmQgYW4gPSBzaWduIQ0K\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'CRLF and sendemail.transferencoding=base64'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\tgit send-email \\\n'> 
          <'\t\t--transfer-encoding=base64 \\\n'> <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\temail-using-crlf \\\n'> 
          <'\t\t2>errors >out &&\n'> <'\tsed '>
        ) <1> <Id.Lit_Comma ','> <'/'> <Id.Lit_Other '^'> <Id.Lit_Dollar '$'> <'/d'> 
        (SQ <' msgtxt1 >actual &&\n'> <'\ttest_cmp expected actual\n'>)
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'refusing to send cover letter template'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\trm -fr outdir &&\n'> 
          <'\tgit format-patch --cover-letter -2 -o outdir &&\n'> <'\ttest_must_fail git send-email \\\n'> <'\t\t--from="Example <nobody@example.com>" \\\n'> 
          <'\t\t--to=nobody@example.com \\\n'> <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\toutdir/0002-*.patch \\\n'> 
          <'\t\toutdir/0000-*.patch \\\n'> <'\t\toutdir/0001-*.patch \\\n'> <'\t\t2>errors >out &&\n'> <'\tgrep "SUBJECT HERE" errors &&\n'> 
          <'\ttest -z "$(ls msgtxt*)"\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'--force sends cover letter template anyway'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> <'\trm -fr outdir &&\n'> 
          <'\tgit format-patch --cover-letter -2 -o outdir &&\n'> <'\tgit send-email \\\n'> <'\t\t--force \\\n'> <'\t\t--from="Example <nobody@example.com>" \\\n'> 
          <'\t\t--to=nobody@example.com \\\n'> <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\toutdir/0002-*.patch \\\n'> 
          <'\t\toutdir/0000-*.patch \\\n'> <'\t\toutdir/0001-*.patch \\\n'> <'\t\t2>errors >out &&\n'> <'\t! grep "SUBJECT HERE" errors &&\n'> 
          <'\ttest -n "$(ls msgtxt*)"\n'>
        )
      }
    )
    (command.ShFunction
      name: test_cover_addresses
      body: 
        (BraceGroup
          children: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:header)
                  op: assign_op.Equal
                  rhs: {(DQ ($ Id.VSub_Number '$1'))}
                  spids: [3502]
                )
              ]
            )
            (C {<shift>})
            (command.AndOr
              ops: [
                Id.Op_DAmp
                Id.Op_DAmp
                Id.Op_DAmp
                Id.Op_DAmp
                Id.Op_DAmp
                Id.Op_DAmp
                Id.Op_DAmp
                Id.Op_DAmp
                Id.Op_DAmp
                Id.Op_DAmp
                Id.Op_DAmp
                Id.Op_DAmp
              ]
              children: [
                (C {<clean_fake_sendmail>})
                (C {<rm>} {<-fr>} {<outdir>})
                (C {<git>} {<format-patch>} {<--cover-letter>} {<-2>} {<-o>} {<outdir>})
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:cover)
                      op: assign_op.Equal
                      rhs: 
                        {
                          (command_sub
                            left_token: <Id.Left_DollarParen '$('>
                            child: (C {<echo>} {<'outdir/0000-'> <Id.Lit_Star '*'> <.patch>})
                          )
                        }
                      spids: [3540]
                    )
                  ]
                )
                (C {<mv>} {($ Id.VSub_DollarName '$cover')} {<cover-to-edit.patch>})
                (command.Simple
                  words: [
                    {<perl>}
                    {<-pe>}
                    {
                      (DQ <'s/^From:/'> ($ Id.VSub_DollarName '$header') <': extra'> 
                        <Id.Lit_BadBackslash '\\'> <'@address.com'> <Id.Lit_BadBackslash '\\'> <'nFrom:/'>
                      )
                    }
                    {<cover-to-edit.patch>}
                  ]
                  redirects: [
                    (redir
                      op: <Id.Redir_Great '>'>
                      loc: (redir_loc.Fd fd:1)
                      arg: {(DQ ($ Id.VSub_DollarName '$cover'))}
                    )
                  ]
                  do_fork: T
                )
                (command.Simple
                  words: [
                    {<git>}
                    {<send-email>}
                    {<--force>}
                    {<--from> <Id.Lit_Equals '='> (DQ <'Example <nobody@example.com>'>)}
                    {<--no-to>}
                    {<--no-cc>}
                    {(DQ ($ Id.VSub_At '$@'))}
                    {<--smtp-server> <Id.Lit_Equals '='> 
                      (DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})) 
                        <'/fake.sendmail'>
                      )
                    }
                    {<'outdir/0000-'> <Id.Lit_Star '*'> <.patch>}
                    {<'outdir/0001-'> <Id.Lit_Star '*'> <.patch>}
                    {<'outdir/0002-'> <Id.Lit_Star '*'> <.patch>}
                  ]
                  redirects: [
                    (redir
                      op: <Id.Redir_Great '2>'>
                      loc: (redir_loc.Fd fd:2)
                      arg: {<errors>}
                    )
                    (redir
                      op: <Id.Redir_Great '>'>
                      loc: (redir_loc.Fd fd:1)
                      arg: {<out>}
                    )
                  ]
                  do_fork: T
                )
                (command.Simple
                  words: [
                    {<grep>}
                    {(DQ <'^'> ($ Id.VSub_DollarName '$header') <': extra@address.com'>)}
                    {<msgtxt1>}
                  ]
                  redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<to1>})]
                  do_fork: T
                )
                (command.Simple
                  words: [
                    {<grep>}
                    {(DQ <'^'> ($ Id.VSub_DollarName '$header') <': extra@address.com'>)}
                    {<msgtxt2>}
                  ]
                  redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<to2>})]
                  do_fork: T
                )
                (command.Simple
                  words: [
                    {<grep>}
                    {(DQ <'^'> ($ Id.VSub_DollarName '$header') <': extra@address.com'>)}
                    {<msgtxt3>}
                  ]
                  redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<to3>})]
                  do_fork: T
                )
                (C {<test_line_count>} {<Id.Lit_Equals '='>} {<1>} {<to1>})
                (C {<test_line_count>} {<Id.Lit_Equals '='>} {<1>} {<to2>})
                (C {<test_line_count>} {<Id.Lit_Equals '='>} {<1>} {<to3>})
              ]
            )
          ]
        )
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'to-cover adds To to all mail'>)} 
      {(SQ <'\n'> <'\ttest_cover_addresses "To" --to-cover\n'>)}
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'cc-cover adds Cc to all mail'>)} 
      {(SQ <'\n'> <'\ttest_cover_addresses "Cc" --cc-cover\n'>)}
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'tocover adds To to all mail'>)} 
      {(SQ <'\n'> <'\ttest_config sendemail.tocover true &&\n'> <'\ttest_cover_addresses "To"\n'>)}
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'cccover adds Cc to all mail'>)} 
      {(SQ <'\n'> <'\ttest_config sendemail.cccover true &&\n'> <'\ttest_cover_addresses "Cc"\n'>)}
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'escaped quotes in sendemail.aliasfiletype=mutt'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> 
          <'\techo "alias sbd \\\\\\"Dot U. Sir\\\\\\" <somebody@example.org>" >.mutt &&\n'> <'\tgit config --replace-all sendemail.aliasesfile "$(pwd)/.mutt" &&\n'> 
          <'\tgit config sendemail.aliasfiletype mutt &&\n'> <'\tgit send-email \\\n'> <'\t\t--from="Example <nobody@example.com>" \\\n'> <'\t\t--to=sbd \\\n'> 
          <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\toutdir/0001-*.patch \\\n'> <'\t\t2>errors >out &&\n'> 
          <'\tgrep "^!somebody@example\\.org!$" commandline1 &&\n'> <'\tgrep -F "To: \\"Dot U. Sir\\" <somebody@example.org>" out\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'sendemail.aliasfiletype=mailrc'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> 
          <'\techo "alias sbd  somebody@example.org" >.mailrc &&\n'> <'\tgit config --replace-all sendemail.aliasesfile "$(pwd)/.mailrc" &&\n'> 
          <'\tgit config sendemail.aliasfiletype mailrc &&\n'> <'\tgit send-email \\\n'> <'\t\t--from="Example <nobody@example.com>" \\\n'> <'\t\t--to=sbd \\\n'> 
          <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\toutdir/0001-*.patch \\\n'> <'\t\t2>errors >out &&\n'> 
          <'\tgrep "^!somebody@example\\.org!$" commandline1\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'sendemail.aliasfile=~/.mailrc'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> 
          <'\techo "alias sbd  someone@example.org" >"$HOME/.mailrc" &&\n'> <'\tgit config --replace-all sendemail.aliasesfile "~/.mailrc" &&\n'> 
          <'\tgit config sendemail.aliasfiletype mailrc &&\n'> <'\tgit send-email \\\n'> <'\t\t--from="Example <nobody@example.com>" \\\n'> <'\t\t--to=sbd \\\n'> 
          <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\toutdir/0001-*.patch \\\n'> <'\t\t2>errors >out &&\n'> 
          <'\tgrep "^!someone@example\\.org!$" commandline1\n'>
        )
      }
    )
    (command.ShFunction
      name: test_dump_aliases
      body: 
        (BraceGroup
          children: [
            (command.AndOr
              ops: [Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp]
              children: [
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:msg)
                      op: assign_op.Equal
                      rhs: {(DQ ($ Id.VSub_Number '$1'))}
                      spids: [3873]
                    )
                  ]
                )
                (C {<shift>})
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:filetype)
                      op: assign_op.Equal
                      rhs: {(DQ ($ Id.VSub_Number '$1'))}
                      spids: [3885]
                    )
                  ]
                )
                (C {<shift>})
                (command.Simple
                  words: [{<printf>} {(SQ <'%s\\n'>)} {(DQ ($ Id.VSub_At '$@'))}]
                  redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>})]
                  do_fork: T
                )
                (command.Simple
                  words: [{<cat>}]
                  redirects: [
                    (redir
                      op: <Id.Redir_Great '>'>
                      loc: (redir_loc.Fd fd:1)
                      arg: {<.tmp-email-aliases>}
                    )
                  ]
                  do_fork: T
                )
                (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
                  {(DQ ($ Id.VSub_DollarName '$msg'))} 
                  {
                    (SQ <'\n'> <'\t\tclean_fake_sendmail && rm -fr outdir &&\n'> 
                      <'\t\tgit config --replace-all sendemail.aliasesfile \\\n'> <'\t\t\t"$(pwd)/.tmp-email-aliases" &&\n'> <'\t\tgit config sendemail.aliasfiletype "$filetype" &&\n'> 
                      <'\t\tgit send-email --dump-aliases 2>errors >actual &&\n'> <'\t\ttest_cmp expect actual\n'> <'\t'>
                    )
                  }
                )
              ]
            )
          ]
        )
    )
    (command.Simple
      words: [
        {<test_dump_aliases>}
        {(SQ <'--dump-aliases sendmail format'>)}
        {(SQ <sendmail>)}
        {(SQ <abgroup>)}
        {(SQ <alice>)}
        {(SQ <bcgrp>)}
        {(SQ <bob>)}
        {(SQ <chloe>)}
      ]
      redirects: [
        (redir
          op: <Id.Redir_DLessDash '<<-'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\E'>) <OF>}
              here_end_span_id: 3995
              stdin_parts: [
                <'alice: Alice W Land <awol@example.com>\n'>
                <'bob: Robert Bobbyton <bob@example.com>\n'>
                <'chloe: chloe@example.com\n'>
                <'abgroup: alice, bob\n'>
                <'bcgrp: bob, chloe, Other <o@example.com>\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (command.Simple
      words: [
        {<test_dump_aliases>}
        {(SQ <'--dump-aliases mutt format'>)}
        {(SQ <mutt>)}
        {(SQ <alice>)}
        {(SQ <bob>)}
        {(SQ <chloe>)}
        {(SQ <donald>)}
      ]
      redirects: [
        (redir
          op: <Id.Redir_DLessDash '<<-'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\E'>) <OF>}
              here_end_span_id: 4041
              stdin_parts: [
                <'alias alice Alice W Land <awol@example.com>\n'>
                <'alias donald Donald C Carlton <donc@example.com>\n'>
                <'alias bob Robert Bobbyton <bob@example.com>\n'>
                <'alias chloe chloe@example.com\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (command.Simple
      words: [
        {<test_dump_aliases>}
        {(SQ <'--dump-aliases mailrc format'>)}
        {(SQ <mailrc>)}
        {(SQ <alice>)}
        {(SQ <bob>)}
        {(SQ <chloe>)}
        {(SQ <eve>)}
      ]
      redirects: [
        (redir
          op: <Id.Redir_DLessDash '<<-'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\E'>) <OF>}
              here_end_span_id: 4087
              stdin_parts: [
                <'alias alice   Alice W Land <awol@example.com>\n'>
                <'alias eve     Eve <eve@example.com>\n'>
                <'alias bob     Robert Bobbyton <bob@example.com>\n'>
                <'alias chloe   chloe@example.com\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (command.Simple
      words: [
        {<test_dump_aliases>}
        {(SQ <'--dump-aliases pine format'>)}
        {(SQ <pine>)}
        {(SQ <alice>)}
        {(SQ <bob>)}
        {(SQ <chloe>)}
        {(SQ <eve>)}
      ]
      redirects: [
        (redir
          op: <Id.Redir_DLessDash '<<-'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\E'>) <OF>}
              here_end_span_id: 4133
              stdin_parts: [
                <'alice\tAlice W Land\t<awol@example.com>\n'>
                <'eve\tEve\t<eve@example.com>\n'>
                <'bob\tRobert\tBobbyton <bob@example.com>\n'>
                <'chloe\t\tchloe@example.com\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (command.Simple
      words: [
        {<test_dump_aliases>}
        {(SQ <'--dump-aliases gnus format'>)}
        {(SQ <gnus>)}
        {(SQ <alice>)}
        {(SQ <bob>)}
        {(SQ <chloe>)}
        {(SQ <eve>)}
      ]
      redirects: [
        (redir
          op: <Id.Redir_DLessDash '<<-'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\E'>) <OF>}
              here_end_span_id: 4179
              stdin_parts: [
                <'(define-mail-alias "alice" "awol@example.com")\n'>
                <'(define-mail-alias "eve" "eve@example.com")\n'>
                <'(define-mail-alias "bob" "bob@example.com")\n'>
                <'(define-mail-alias "chloe" "chloe@example.com")\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'--dump-aliases must be used alone'>)} 
      {
        (SQ <'\n'> 
          <
'\ttest_must_fail git send-email --dump-aliases --to=janice@example.com -1 refs/heads/accounting\n'
          >
        )
      }
    )
    (command.ShFunction
      name: test_sendmail_aliases
      body: 
        (BraceGroup
          children: [
            (command.AndOr
              ops: [Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp]
              children: [
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:msg)
                      op: assign_op.Equal
                      rhs: {(DQ ($ Id.VSub_Number '$1'))}
                      spids: [4201]
                    )
                  ]
                )
                (C {<shift>})
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:expect)
                      op: assign_op.Equal
                      rhs: {(DQ ($ Id.VSub_At '$@'))}
                      spids: [4213]
                    )
                  ]
                )
                (command.Simple
                  words: [{<cat>}]
                  redirects: [
                    (redir
                      op: <Id.Redir_Great '>'>
                      loc: (redir_loc.Fd fd:1)
                      arg: {<.tmp-email-aliases>}
                    )
                  ]
                  do_fork: T
                )
                (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
                  {(DQ ($ Id.VSub_DollarName '$msg'))} 
                  {
                    (SQ <'\n'> <'\t\tclean_fake_sendmail && rm -fr outdir &&\n'> 
                      <'\t\tgit format-patch -1 -o outdir &&\n'> <'\t\tgit config --replace-all sendemail.aliasesfile \\\n'> <'\t\t\t"$(pwd)/.tmp-email-aliases" &&\n'> 
                      <'\t\tgit config sendemail.aliasfiletype sendmail &&\n'> <'\t\tgit send-email \\\n'> <'\t\t\t--from="Example <nobody@example.com>" \\\n'> 
                      <'\t\t\t--to=alice --to=bcgrp \\\n'> <'\t\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\t\toutdir/0001-*.patch \\\n'> 
                      <'\t\t\t2>errors >out &&\n'> <'\t\tfor i in $expect\n'> <'\t\tdo\n'> <'\t\t\tgrep "^!$i!$" commandline1 || return 1\n'> 
                      <'\t\tdone\n'> <'\t'>
                    )
                  }
                )
              ]
            )
          ]
        )
    )
    (command.Simple
      words: [
        {<test_sendmail_aliases>}
        {(SQ <'sendemail.aliasfiletype=sendmail'>)}
        {(SQ <'awol@example\\.com'>)}
        {(SQ <'bob@example\\.com'>)}
        {(SQ <'chloe@example\\.com'>)}
        {(SQ <'o@example\\.com'>)}
      ]
      redirects: [
        (redir
          op: <Id.Redir_DLessDash '<<-'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\E'>) <OF>}
              here_end_span_id: 4302
              stdin_parts: [
                <'alice: Alice W Land <awol@example.com>\n'>
                <'bob: Robert Bobbyton <bob@example.com>\n'>
                <'# this is a comment\n'>
                <'   # this is also a comment\n'>
                <'chloe: chloe@example.com\n'>
                <'abgroup: alice, bob\n'>
                <'bcgrp: bob, chloe, Other <o@example.com>\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (command.Simple
      words: [
        {<test_sendmail_aliases>}
        {(SQ <'sendmail aliases line folding'>)}
        {<alice1>}
        {<bob1>}
        {<bob2>}
        {<chuck1>}
        {<chuck2>}
        {<darla1>}
        {<darla2>}
        {<darla3>}
        {<elton1>}
        {<elton2>}
        {<elton3>}
        {<fred1>}
        {<fred2>}
        {<greg1>}
      ]
      redirects: [
        (redir
          op: <Id.Redir_DLessDash '<<-'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\E'>) <OF>}
              here_end_span_id: 4371
              stdin_parts: [
                <'alice: alice1\n'>
                <'bob: bob1,\\\n'>
                <'bob2\n'>
                <'chuck: chuck1,\n'>
                <'    chuck2\n'>
                <'darla: darla1,\\\n'>
                <'darla2,\n'>
                <'    darla3\n'>
                <'elton: elton1,\n'>
                <'    elton2,\\\n'>
                <'elton3\n'>
                <'fred: fred1,\\\n'>
                <'    fred2\n'>
                <'greg: greg1\n'>
                <'bcgrp: bob, chuck, darla, elton, fred, greg\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (command.Simple
      words: [
        {<test_sendmail_aliases>}
        {(SQ <'sendmail aliases tolerate bogus line folding'>)}
        {<alice1>}
        {<bob1>}
      ]
      redirects: [
        (redir
          op: <Id.Redir_DLessDash '<<-'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\E'>) <OF>}
              here_end_span_id: 4391
              stdin_parts: [<'    alice: alice1\n'> <'bcgrp: bob1\\\n'>]
            )
        )
      ]
      do_fork: T
    )
    (command.Simple
      words: [{<test_sendmail_aliases>} {(SQ <'sendmail aliases empty'>)} {<alice>} {<bcgrp>}]
      redirects: [
        (redir
          op: <Id.Redir_DLessDash '<<-'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\E'>) <OF>}
              here_end_span_id: 4407
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'alias support in To header'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> 
          <'\techo "alias sbd  someone@example.org" >.mailrc &&\n'> <'\ttest_config sendemail.aliasesfile ".mailrc" &&\n'> 
          <'\ttest_config sendemail.aliasfiletype mailrc &&\n'> <'\tgit format-patch --stdout -1 --to=sbd >aliased.patch &&\n'> <'\tgit send-email \\\n'> 
          <'\t\t--from="Example <nobody@example.com>" \\\n'> <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\taliased.patch \\\n'> <'\t\t2>errors >out &&\n'> 
          <'\tgrep "^!someone@example\\.org!$" commandline1\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'alias support in Cc header'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> 
          <'\techo "alias sbd  someone@example.org" >.mailrc &&\n'> <'\ttest_config sendemail.aliasesfile ".mailrc" &&\n'> 
          <'\ttest_config sendemail.aliasfiletype mailrc &&\n'> <'\tgit format-patch --stdout -1 --cc=sbd >aliased.patch &&\n'> <'\tgit send-email \\\n'> 
          <'\t\t--from="Example <nobody@example.com>" \\\n'> <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\taliased.patch \\\n'> <'\t\t2>errors >out &&\n'> 
          <'\tgrep "^!someone@example\\.org!$" commandline1\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'tocmd works with aliases'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> 
          <'\techo "alias sbd  someone@example.org" >.mailrc &&\n'> <'\ttest_config sendemail.aliasesfile ".mailrc" &&\n'> 
          <'\ttest_config sendemail.aliasfiletype mailrc &&\n'> <'\tgit format-patch --stdout -1 >tocmd.patch &&\n'> <'\techo tocmd--sbd >>tocmd.patch &&\n'> 
          <'\tgit send-email \\\n'> <'\t\t--from="Example <nobody@example.com>" \\\n'> <'\t\t--to-cmd=./tocmd-sed \\\n'> 
          <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\ttocmd.patch \\\n'> <'\t\t2>errors >out &&\n'> 
          <'\tgrep "^!someone@example\\.org!$" commandline1\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'cccmd works with aliases'>)} 
      {
        (SQ <'\n'> <'\tclean_fake_sendmail &&\n'> 
          <'\techo "alias sbd  someone@example.org" >.mailrc &&\n'> <'\ttest_config sendemail.aliasesfile ".mailrc" &&\n'> 
          <'\ttest_config sendemail.aliasfiletype mailrc &&\n'> <'\tgit format-patch --stdout -1 >cccmd.patch &&\n'> <'\techo cccmd--sbd >>cccmd.patch &&\n'> 
          <'\tgit send-email \\\n'> <'\t\t--from="Example <nobody@example.com>" \\\n'> <'\t\t--cc-cmd=./cccmd-sed \\\n'> 
          <'\t\t--smtp-server="$(pwd)/fake.sendmail" \\\n'> <'\t\tcccmd.patch \\\n'> <'\t\t2>errors >out &&\n'> 
          <'\tgrep "^!someone@example\\.org!$" commandline1\n'>
        )
      }
    )
    (command.ShFunction
      name: do_xmailer_test
      body: 
        (BraceGroup
          children: [
            (command.AndOr
              ops: [Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp]
              children: [
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:expected)
                      op: assign_op.Equal
                      rhs: {($ Id.VSub_Number '$1')}
                      spids: [4517]
                    )
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:params)
                      op: assign_op.Equal
                      rhs: {($ Id.VSub_Number '$2')}
                      spids: [4520]
                    )
                  ]
                )
                (C {<git>} {<format-patch>} {<-1>})
                (command.Simple
                  words: [
                    {<git>}
                    {<send-email>}
                    {<--from> <Id.Lit_Equals '='> (DQ <'Example <nobody@example.com>'>)}
                    {<--to> <Id.Lit_Equals '='> <someone> <Id.Lit_Splice '@example'> <.com>}
                    {<--smtp-server> <Id.Lit_Equals '='> 
                      (DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})) 
                        <'/fake.sendmail'>
                      )
                    }
                    {($ Id.VSub_DollarName '$params')}
                    {<0001-> <Id.Lit_Star '*'> <.patch>}
                  ]
                  redirects: [
                    (redir
                      op: <Id.Redir_Great '2>'>
                      loc: (redir_loc.Fd fd:2)
                      arg: {<errors>}
                    )
                    (redir
                      op: <Id.Redir_Great '>'>
                      loc: (redir_loc.Fd fd:1)
                      arg: {<out>}
                    )
                  ]
                  do_fork: T
                )
                (BraceGroup
                  children: [
                    (command.Sentence
                      child: 
                        (command.AndOr
                          ops: [Id.Op_DPipe]
                          children: [(C {<grep>} {(SQ <'^X-Mailer:'>)} {<out>}) (C {<Id.Lit_Colon ':'>})]
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<mailer>})]
                )
                (C {<test_line_count>} {<Id.Lit_Equals '='>} {($ Id.VSub_DollarName '$expected')} 
                  {<mailer>}
                )
              ]
            )
          ]
        )
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'--[no-]xmailer without any configuration'>)} {(SQ <'\n'> <'\tdo_xmailer_test 1 "--xmailer" &&\n'> <'\tdo_xmailer_test 0 "--no-xmailer"\n'>)}
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'--[no-]xmailer with sendemail.xmailer=true'>)} 
      {
        (SQ <'\n'> <'\ttest_config sendemail.xmailer true &&\n'> <'\tdo_xmailer_test 1 "" &&\n'> 
          <'\tdo_xmailer_test 0 "--no-xmailer" &&\n'> <'\tdo_xmailer_test 1 "--xmailer"\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'--[no-]xmailer with sendemail.xmailer=false'>)} 
      {
        (SQ <'\n'> <'\ttest_config sendemail.xmailer false &&\n'> <'\tdo_xmailer_test 0 "" &&\n'> 
          <'\tdo_xmailer_test 0 "--no-xmailer" &&\n'> <'\tdo_xmailer_test 1 "--xmailer"\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'setup expected-list'>)} 
      {
        (SQ <'\n'> <'\tgit send-email \\\n'> <'\t--dry-run \\\n'> 
          <'\t--from="Example <from@example.com>" \\\n'> <'\t--to="To 1 <to1@example.com>" \\\n'> <'\t--to="to2@example.com" \\\n'> 
          <'\t--to="to3@example.com" \\\n'> <'\t--cc="Cc 1 <cc1@example.com>" \\\n'> <'\t--cc="Cc2 <cc2@example.com>" \\\n'> 
          <'\t--bcc="bcc1@example.com" \\\n'> <'\t--bcc="bcc2@example.com" \\\n'> <'\t0001-add-master.patch | replace_variable_fields \\\n'> 
          <'\t>expected-list\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'use email list in --cc --to and --bcc'>)} 
      {
        (SQ <'\n'> <'\tgit send-email \\\n'> <'\t--dry-run \\\n'> 
          <'\t--from="Example <from@example.com>" \\\n'> <'\t--to="To 1 <to1@example.com>, to2@example.com" \\\n'> <'\t--to="to3@example.com" \\\n'> 
          <'\t--cc="Cc 1 <cc1@example.com>, Cc2 <cc2@example.com>" \\\n'> <'\t--bcc="bcc1@example.com, bcc2@example.com" \\\n'> 
          <'\t0001-add-master.patch | replace_variable_fields \\\n'> <'\t>actual-list &&\n'> <'\ttest_cmp expected-list actual-list\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} {(SQ <'aliases work with email list'>)} 
      {
        (SQ <'\n'> <'\techo "alias to2 to2@example.com" >.mutt &&\n'> 
          <'\techo "alias cc1 Cc 1 <cc1@example.com>" >>.mutt &&\n'> <'\ttest_config sendemail.aliasesfile ".mutt" &&\n'> 
          <'\ttest_config sendemail.aliasfiletype mutt &&\n'> <'\tgit send-email \\\n'> <'\t--dry-run \\\n'> <'\t--from="Example <from@example.com>" \\\n'> 
          <'\t--to="To 1 <to1@example.com>, to2, to3@example.com" \\\n'> <'\t--cc="cc1, Cc2 <cc2@example.com>" \\\n'> <'\t--bcc="bcc1@example.com, bcc2@example.com" \\\n'> 
          <'\t0001-add-master.patch | replace_variable_fields \\\n'> <'\t>actual-list &&\n'> <'\ttest_cmp expected-list actual-list\n'>
        )
      }
    )
    (C {<test_expect_success>} {($ Id.VSub_DollarName '$PREREQ')} 
      {(SQ <'leading and trailing whitespaces are removed'>)} 
      {
        (SQ <'\n'> <'\techo "alias to2 to2@example.com" >.mutt &&\n'> 
          <'\techo "alias cc1 Cc 1 <cc1@example.com>" >>.mutt &&\n'> <'\ttest_config sendemail.aliasesfile ".mutt" &&\n'> 
          <'\ttest_config sendemail.aliasfiletype mutt &&\n'> <'\tTO1=$(echo "QTo 1 <to1@example.com>" | q_to_tab) &&\n'> 
          <'\tTO2=$(echo "QZto2" | qz_to_tab_space) &&\n'> <'\tCC1=$(echo "cc1" | append_cr) &&\n'> <'\tBCC1=$(echo "Q bcc1@example.com Q" | q_to_nul) &&\n'> 
          <'\tgit send-email \\\n'> <'\t--dry-run \\\n'> <'\t--from="\tExample <from@example.com>" \\\n'> <'\t--to="$TO1" \\\n'> 
          <'\t--to="$TO2" \\\n'> <'\t--to="  to3@example.com   " \\\n'> <'\t--cc="$CC1" \\\n'> <'\t--cc="Cc2 <cc2@example.com>" \\\n'> 
          <'\t--bcc="$BCC1" \\\n'> <'\t--bcc="bcc2@example.com" \\\n'> <'\t0001-add-master.patch | replace_variable_fields \\\n'> 
          <'\t>actual-list &&\n'> <'\ttest_cmp expected-list actual-list\n'>
        )
      }
    )
    (C {<test_done>})
  ]
)