Re: [PATCH v4 3/3] t4113: put executable lines to test_expect_success

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 8, 2023 at 2:57 AM Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> wrote:
> In this case the syntax you're trying to get working is something we
> usually try to avoid in either case, i.e. even if it involves an
> external process we usually do:
>
>         cat >out <<-\EOF
>         a
>         b
>         c
>         EOF
>
> Rather than:
>
>         echo "a
>         b
>         c" >out

The here-doc (<<-\EOF) form is definitely a good idea when the code is
part of an indented test body, whereas the multi-line double-quoted
string will be problematic since lines "b" and "c" will be indented
with TAB, which is undesirable here.

Even better for such a simple case would be:

    test_write_lines a b c >out &&

In fact, Junio made this suggestion in the form of a code snipped much
earlier in this thread.

> If you are using "echo" I saw another change of yours had e.g.:
>
>         echo x >f &&
>         echo y >>f &&
>         echo z >>f
>
> It's better to e.g. (assuming use of "echo", or other built-ins or
> commands):
>
>         {
>                 echo x &&
>                 echo y &&
>                 echo z
>         } >f

This is also an improvement, though test_write_lines would (again) be
even better for such a simple case:

    test_write_lines x y z >f &&



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux