All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Kacper Kornet <draenog@pld-linux.org>
Cc: Junio C Hamano <gitster@pobox.com>,
	Johan Herland <johan@herland.net>,
	git@vger.kernel.org
Subject: Re: [PATCH] Fix unclosed here document in t3301.sh
Date: Thu, 22 Jan 2015 07:38:52 -0500	[thread overview]
Message-ID: <20150122123851.GA19681@peff.net> (raw)
In-Reply-To: <20150122115936.GA2358@camk.edu.pl>

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

      parent reply	other threads:[~2015-01-22 12:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150122123851.GA19681@peff.net \
    --to=peff@peff.net \
    --cc=draenog@pld-linux.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johan@herland.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.