Re: [PATCH 4/4] unpack-trees: support super-prefix option
- From
Stefan Beller <sbeller@google.com>
- Date
- Jan 11, 2017, 23:57 UTC
- Message-ID
- <CAGZ79kb30nG-TAnXuUKM+exxoh816sRogwhU-hjaL+onmFR-qQ@mail.gmail.com>
- In-Reply-To
- <xmqqh955mb1p.fsf@gitster.mtv.corp.google.com>
On Wed, Jan 11, 2017 at 3:28 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 17 quoted lines
> Stefan Beller <sbeller@google.com> writes: > >>> Preparing the expected output "expect" outside test_expect_success >>> block is also old-school. Move it inside the new test? >> >> I looked into that. What is our current stance on using single/double quotes? > > Using dq around executable part, i.e. > > test_expect_success title " > echo \"'foo'\" > " > > is a million-times more grave sin even if the test initially does > not refer to any variable in its body. Somebody will eventually > need to add a line that refers to a variable and either forgets to > quote \$ in front or properly quotes it.
agreed.
Show 17 quoted lines
> The former makes the
> variable interpolated while the arguments to the test_expect_success
> is prepared (which is a bug) and the latter makes the result quite
> ugly, like so:
>
> test_expect_success title "
> sq=\' var=foo &&
> echo \"\${sq}\$value\${sq}\"
> "
>
> Enclosing the body always in sq-pair does mean something ugly like
> this from the beginning once you need to use sq inside:
>
> test_expect_success title '
> sq='\'' &&
> echo "${sq}foo${sq}"
> 'This one fails
error: bug in the test script: broken &&-chain:
sq=' &&
echo "${sq}foo${sq}"
both other occurrences of using ${sq} are defining sq outside
(one as sq=\' and the other as sq="'")So I think we either have to keep sq out of the test,
sq="'"
test_expect_success title '
echo "${sq}foo${sq}"
'or do the echo/printf trick inside:
test_expect_success title '
sq=$(echo -e "\x27") &&
echo "${sq}foo${sq}"
'Eh, I just realize the '\'' works inside here-doc, too. Nevermind then, I'll resend it with just quoted sq in the here-doc then.
Thanks, Stefan