{"thread":{"id":"38430","subject":"[PATCH] Fix unclosed here document in t3301.sh","startedAt":"2015-01-22T11:59:36Z","lastAt":"2015-01-22T12:38:52Z","messageCount":3,"participants":["Kacper Kornet","Jeff King","Johan Herland"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"255085","messageId":"20150122115936.GA2358@camk.edu.pl","threadId":"38430","inReplyTo":null,"subject":"[PATCH] Fix unclosed here document in t3301.sh","fromName":"Kacper Kornet","fromEmail":"draenog@pld-linux.org","sentAt":"2015-01-22T11:59:36Z","receivedAt":"2015-01-22T11:59:36Z","isPatch":true,"sender":{"key":"draenog@pld-linux.org","avatar":"https://avatars.githubusercontent.com/u/608762?v=4"},"body":"Commit 908a3203632a02568df230c0fccf9a2cd8da24e6 introduced  indentation\nto here documents in t3301.sh. However in one place <<-EOF was missing\n-, which broke this test when run with mksh-50d. This commit fixes it.\n\nSigned-off-by: Kacper Kornet <draenog@pld-linux.org>\n---\n t/t3301-notes.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/t3301-notes.sh b/t/t3301-notes.sh\nindex 245406a..433f925 100755\n--- a/t/t3301-notes.sh\n+++ b/t/t3301-notes.sh\n@@ -658,7 +658,7 @@ test_expect_success '--show-notes=* adds to GIT_NOTES_DISPLAY_REF' '\n '\n \n test_expect_success '--no-standard-notes' '\n-\tcat >expect-commits <<EOF\n+\tcat >expect-commits <<-EOF\n \t\tcommit 2c125331118caba0ff8238b7f4958ac6e93fe39c\n \t\tAuthor: A U Thor <author@example.com>\n \t\tDate:   Thu Apr 7 15:18:13 2005 -0700\n-- \n2.2.2\n"},{"id":"255087","messageId":"CALKQrgdDfcGtk9MWdfQTC7hSgkDAWjN1O_U6F4BCJdMjoULD7Q@mail.gmail.com","threadId":"38430","inReplyTo":"20150122115936.GA2358@camk.edu.pl","subject":"Re: [PATCH] Fix unclosed here document in t3301.sh","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2015-01-22T12:21:23Z","receivedAt":"2015-01-22T12:21:23Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"On Thu, Jan 22, 2015 at 12:59 PM, Kacper Kornet <draenog@pld-linux.org> wrote:\n> Commit 908a3203632a02568df230c0fccf9a2cd8da24e6 introduced  indentation\n> to here documents in t3301.sh. However in one place <<-EOF was missing\n> -, which broke this test when run with mksh-50d. This commit fixes it.\n>\n> Signed-off-by: Kacper Kornet <draenog@pld-linux.org>\n\nAcked-by: Johan Herland <johan@herland.net>\n\n> ---\n>  t/t3301-notes.sh | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh\n> index 245406a..433f925 100755\n> --- a/t/t3301-notes.sh\n> +++ b/t/t3301-notes.sh\n> @@ -658,7 +658,7 @@ test_expect_success '--show-notes=* adds to GIT_NOTES_DISPLAY_REF' '\n>  '\n>\n>  test_expect_success '--no-standard-notes' '\n> -       cat >expect-commits <<EOF\n> +       cat >expect-commits <<-EOF\n>                 commit 2c125331118caba0ff8238b7f4958ac6e93fe39c\n>                 Author: A U Thor <author@example.com>\n>                 Date:   Thu Apr 7 15:18:13 2005 -0700\n> --\n> 2.2.2\n\n\n\n-- \nJohan Herland, <johan@herland.net>\nwww.herland.net\n"},{"id":"255086","messageId":"20150122123851.GA19681@peff.net","threadId":"38430","inReplyTo":"20150122115936.GA2358@camk.edu.pl","subject":"Re: [PATCH] Fix unclosed here document in t3301.sh","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-01-22T12:38:52Z","receivedAt":"2015-01-22T12:38:52Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Jan 22, 2015 at 12:59:36PM +0100, Kacper Kornet wrote:\n\n> Commit 908a3203632a02568df230c0fccf9a2cd8da24e6 introduced  indentation\n> to here documents in t3301.sh. However in one place <<-EOF was missing\n> -, which broke this test when run with mksh-50d. This commit fixes it.\n\nThis is definitely the right direction, but I was a little surprised it\nworked at all on other shells! Both bash and dash end the here-doc at\nthe end of the input (in this case the end of the eval string). They end\nup sucking the EOF and the follow-on commands into the here-doc, and the\ntest literally does nothing except the call to cat.\n\nBash does print a warning in this case. It would be nice to upgrade it\nto an error (so at least bash users could easily detect the buggy\nscript), but I don't see any way to do so. I guess running with mksh is\na good substitute. :)\n\nHowever, in most such instances of this problem, the shell will notice\nand barf, because it syntactically expects more on the next line:\n\n  $ sh -c '\n    cat >foo <<EOF &&\n    whatever\n    EOF\n    do_something\n  '\n  sh: 6: Syntax error: end of file unexpected\n\nSo the problem in this instance is that the here-doc marker is wrong\n_and_ the test accidentally broke the &&-chaining:\n\n>  test_expect_success '--no-standard-notes' '\n> -\tcat >expect-commits <<EOF\n> +\tcat >expect-commits <<-EOF\n\nThe ideal line here would be:\n\n  cat >expect-commits <<-EOF &&\n\n-Peff\n"}]}