git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix unclosed here document in t3301.sh
@ 2015-01-22 11:59 Kacper Kornet
  2015-01-22 12:21 ` Johan Herland
  2015-01-22 12:38 ` Jeff King
  0 siblings, 2 replies; 3+ messages in thread
From: Kacper Kornet @ 2015-01-22 11:59 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johan Herland, git

Commit 908a3203632a02568df230c0fccf9a2cd8da24e6 introduced  indentation
to here documents in t3301.sh. However in one place <<-EOF was missing
-, which broke this test when run with mksh-50d. This commit fixes it.

Signed-off-by: Kacper Kornet <draenog@pld-linux.org>
---
 t/t3301-notes.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh
index 245406a..433f925 100755
--- a/t/t3301-notes.sh
+++ b/t/t3301-notes.sh
@@ -658,7 +658,7 @@ test_expect_success '--show-notes=* adds to GIT_NOTES_DISPLAY_REF' '
 '
 
 test_expect_success '--no-standard-notes' '
-	cat >expect-commits <<EOF
+	cat >expect-commits <<-EOF
 		commit 2c125331118caba0ff8238b7f4958ac6e93fe39c
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:18:13 2005 -0700
-- 
2.2.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix unclosed here document in t3301.sh
  2015-01-22 11:59 [PATCH] Fix unclosed here document in t3301.sh Kacper Kornet
@ 2015-01-22 12:21 ` Johan Herland
  2015-01-22 12:38 ` Jeff King
  1 sibling, 0 replies; 3+ messages in thread
From: Johan Herland @ 2015-01-22 12:21 UTC (permalink / raw)
  To: Kacper Kornet; +Cc: Junio C Hamano, Git mailing list

On Thu, Jan 22, 2015 at 12:59 PM, Kacper Kornet <draenog@pld-linux.org> wrote:
> Commit 908a3203632a02568df230c0fccf9a2cd8da24e6 introduced  indentation
> to here documents in t3301.sh. However in one place <<-EOF was missing
> -, which broke this test when run with mksh-50d. This commit fixes it.
>
> Signed-off-by: Kacper Kornet <draenog@pld-linux.org>

Acked-by: Johan Herland <johan@herland.net>

> ---
>  t/t3301-notes.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh
> index 245406a..433f925 100755
> --- a/t/t3301-notes.sh
> +++ b/t/t3301-notes.sh
> @@ -658,7 +658,7 @@ test_expect_success '--show-notes=* adds to GIT_NOTES_DISPLAY_REF' '
>  '
>
>  test_expect_success '--no-standard-notes' '
> -       cat >expect-commits <<EOF
> +       cat >expect-commits <<-EOF
>                 commit 2c125331118caba0ff8238b7f4958ac6e93fe39c
>                 Author: A U Thor <author@example.com>
>                 Date:   Thu Apr 7 15:18:13 2005 -0700
> --
> 2.2.2



-- 
Johan Herland, <johan@herland.net>
www.herland.net

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix unclosed here document in t3301.sh
  2015-01-22 11:59 [PATCH] Fix unclosed here document in t3301.sh Kacper Kornet
  2015-01-22 12:21 ` Johan Herland
@ 2015-01-22 12:38 ` Jeff King
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff King @ 2015-01-22 12:38 UTC (permalink / raw)
  To: Kacper Kornet; +Cc: Junio C Hamano, Johan Herland, git

On Thu, Jan 22, 2015 at 12:59:36PM +0100, Kacper Kornet wrote:

> Commit 908a3203632a02568df230c0fccf9a2cd8da24e6 introduced  indentation
> to here documents in t3301.sh. However in one place <<-EOF was missing
> -, which broke this test when run with mksh-50d. This commit fixes it.

This is definitely the right direction, but I was a little surprised it
worked at all on other shells! Both bash and dash end the here-doc at
the end of the input (in this case the end of the eval string). They end
up sucking the EOF and the follow-on commands into the here-doc, and the
test literally does nothing except the call to cat.

Bash does print a warning in this case. It would be nice to upgrade it
to an error (so at least bash users could easily detect the buggy
script), but I don't see any way to do so. I guess running with mksh is
a good substitute. :)

However, in most such instances of this problem, the shell will notice
and barf, because it syntactically expects more on the next line:

  $ sh -c '
    cat >foo <<EOF &&
    whatever
    EOF
    do_something
  '
  sh: 6: Syntax error: end of file unexpected

So the problem in this instance is that the here-doc marker is wrong
_and_ the test accidentally broke the &&-chaining:

>  test_expect_success '--no-standard-notes' '
> -	cat >expect-commits <<EOF
> +	cat >expect-commits <<-EOF

The ideal line here would be:

  cat >expect-commits <<-EOF &&

-Peff

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-01-22 12:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-22 11:59 [PATCH] Fix unclosed here document in t3301.sh Kacper Kornet
2015-01-22 12:21 ` Johan Herland
2015-01-22 12:38 ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).