All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shuqi Liang <cheskaqiqi@gmail.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH v4 3/3] t4113: put executable lines to test_expect_success
Date: Fri, 10 Feb 2023 10:29:45 -0500	[thread overview]
Message-ID: <CAMO4yUHZ=aUa5pOCKH4F91YhUSgCRuHNXBBOyTF5tzNY=oHsXw@mail.gmail.com> (raw)
In-Reply-To: <230208.865ycc1tqc.gmgdl@evledraar.gmail.com>

Hi Ævar ,

Sorry if  I sent this email twice. I forget to CC  git@vger.kernel.org.

On Wed, Feb 8, 2023 at 2:50 AM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:

> I'm not sure because you're just posting snippets, if you have problems
> in the future it would be best to post the full diff to "master" that
> you're having issues with, e.g. an RFC per Documentation/SubmittingPatches.

Yeah, posting snippets doesn't describe the problem very well. Thanks
for the advice.



> But I think this is because the test itself is using '-quotes, so you
> need to use '\'' if you want to single quote, and " for double quotes,
> and \" if the test were in double quotes.


> But the issues you're having here aren't with Git, but the very basics
> of POSIX shell syntax.

> I think it would be good for you to read some basic documentation on
> POSIX shells, their syntax, common POSIX commands etc. Your local "man
> sh" is probably a good place to start, but there's also books, online
> tutorials etc.

Thanks, will do .  I'll  try to avoid making mistakes on POSIX shells
questions and really learn the basic  POSIX shells syntax.

> 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
>
> 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

Seen I pass the test s, I'v a submit  V5 patch instead of RFC, Would
you mind taking a look at this for me? Looking forward to reply.

-----------------------------
Thanks

Shuqi

On Wed, Feb 8, 2023 at 2:50 AM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
>
>
> On Wed, Feb 08 2023, Shuqi Liang wrote:
>
> > On Tue, Feb 7, 2023 at 3:12 AM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
> >
> >> But this is almost certainly that you're trying to insert leading
> >> whitespace into a line that's in a <<-EOF here-doc, the "-" part of that
> >> means that your leading whitespace is being stripped.
> >>
> >> A typical idiom for that is have a marker for the start of line, and
> >> strip the whitespace with "sed". See this for existing examples:
> >>
> >>         git grep 'sed.*\^.*>.*EOF'
> >
> >
> > I try to use Z as the marker in front of 'a' and 'b' and use sed -e
> > "s/Z/ /g" in order to replace Z with white space but it still can not
> > pass the test.
> >
> > Then I realize even if I don't add tab in front of the line but with
> > space in front of 'a' and 'b' like the original test script. It still
> > says it can't read "b" and "c” :
> >
> > test_expect_success 'apply at the beginning' '
> > cat >test-patch<<\EOF &&
> > diff a/file b/file
> > --- a/file
> > +++ b/file
> > @@ -1,2 +1,3 @@
> > +a
> >  b
> >  c
> > EOF
> >
> > echo >file 'a
> > b
> > c'&&
> > git update-index file&&
> > test_must_fail git apply --index test-patch
> > '
> > Maybe the error is not caused by whitespace?
> >
> > Then I try to change:
> >
> > echo >file 'a
> > b
> > c'
> >
> > To:
> > echo >file "a
> > b
> > c"
> >
> > Then everything passes the test. I think double quotes allow for
> > variable substitution and command substitution, while single quotes
> > preserve the literal value of all characters within the quotes. In
> > this case, the string contains no variables or commands, so either
> > type of quote would work. Is there something wrong with my idea? Is it
> > good to modify code like that?
> >
> > Looking forward to your reply!
>
> I'm not sure because you're just posting snippets, if you have problems
> in the future it would be best to post the full diff to "master" that
> you're having issues with, e.g. an RFC per Documentation/SubmittingPatches.
>
> But I think this is because the test itself is using '-quotes, so you
> need to use '\'' if you want to single quote, and " for double quotes,
> and \" if the test were in double quotes.
>
> But the issues you're having here aren't with Git, but the very basics
> of POSIX shell syntax.
>
> I think it would be good for you to read some basic documentation on
> POSIX shells, their syntax, common POSIX commands etc. Your local "man
> sh" is probably a good place to start, but there's also books, online
> tutorials etc.
>
> 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
>
> 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

  reply	other threads:[~2023-02-10 15:30 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-31 22:49 [GSoC][PATCH] t/t4113-apply-ending.sh: Modernize a test script Shuqi Liang
2023-02-01  2:21 ` Andrei Rybak
2023-02-02 17:20   ` cheska fran
2023-02-02 17:18 ` [PATCH v2 0/4] t4113: modernize test style Shuqi Liang
2023-02-02 17:18   ` [PATCH v2 1/4]t4113: replace backslash with single quote Shuqi Liang
2023-02-02 21:00     ` Junio C Hamano
2023-02-05 14:28       ` Shuqi Liang
2023-02-02 17:18   ` [PATCH v2 2/4] t4113:put second creation in own step Shuqi Liang
2023-02-02 17:18   ` [PATCH v2 3/4] t4113: use "<<-" instead of "<<" Shuqi Liang
2023-02-02 21:05     ` Junio C Hamano
2023-02-05 14:38       ` Shuqi Liang
2023-02-02 17:18   ` [PATCH v2 4/4] t4113: indent with tabs Shuqi Liang
2023-02-02 21:10     ` Junio C Hamano
2023-02-05 14:51       ` Shuqi Liang
2023-02-05 14:52   ` [PATCH v3 0/3] modernize style Shuqi Liang
2023-02-05 14:52     ` [PATCH v3 1/3]t4113: modernize a test script Shuqi Liang
2023-02-05 14:52     ` [PATCH v3 2/3] t4113: put executable lines to test_expect_success Shuqi Liang
2023-02-05 14:52     ` [PATCH v3 3/3] t4113: indent with space Shuqi Liang
2023-02-05 20:29       ` Eric Sunshine
2023-02-06 21:17         ` Shuqi Liang
2023-02-06 21:18     ` [PATCH v4 0/3] t4113: modernize style Shuqi Liang
2023-02-06 21:18       ` [PATCH v4 1/3] t4113: modernize test script Shuqi Liang
2023-02-06 21:18       ` [PATCH v4 2/3] t4113: indent with tab Shuqi Liang
2023-02-06 21:18       ` [PATCH v4 3/3] t4113: put executable lines to test_expect_success Shuqi Liang
2023-02-06 21:50         ` Ævar Arnfjörð Bjarmason
2023-02-06 22:44         ` Junio C Hamano
2023-02-06 23:42           ` Shuqi Liang
2023-02-07  8:05             ` Ævar Arnfjörð Bjarmason
2023-02-07 19:55               ` Shuqi Liang
2023-02-08  5:44               ` Shuqi Liang
2023-02-08  7:44                 ` Ævar Arnfjörð Bjarmason
2023-02-10 15:29                   ` Shuqi Liang [this message]
2023-02-15  0:34                   ` Eric Sunshine
2023-02-15  0:26               ` Eric Sunshine
2023-02-14 22:17           ` Shuqi Liang
2023-02-14 22:29             ` Junio C Hamano
2023-02-09 15:44       ` [PATCH v5 0/3] t4113: modernize style Shuqi Liang
2023-02-09 15:44         ` [PATCH v5 1/3] t4113: modernize test script Shuqi Liang
2023-02-09 15:44         ` [PATCH v5 2/3] t4113: indent with tab Shuqi Liang
2023-02-15  0:10           ` Eric Sunshine
2023-02-15  0:18             ` Shuqi Liang
2023-02-09 15:44         ` [PATCH v5 3/3] t4113: put executable lines to test_expect_success Shuqi Liang
2023-02-15  1:09           ` Eric Sunshine
2023-02-15  2:40             ` Shuqi Liang
2023-02-15  2:38         ` [PATCH v6 0/3] t4113: modernize style Shuqi Liang
2023-02-15  2:39         ` Shuqi Liang
2023-02-15  2:39           ` [PATCH v6 1/3] t4113: modernize test script Shuqi Liang
2023-02-15  2:39           ` [PATCH v6 2/3] t4113: indent with tab Shuqi Liang
2023-02-15  2:39           ` [PATCH v6 3/3] t4113: put executable lines to test_expect_success Shuqi Liang

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='CAMO4yUHZ=aUa5pOCKH4F91YhUSgCRuHNXBBOyTF5tzNY=oHsXw@mail.gmail.com' \
    --to=cheskaqiqi@gmail.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    /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.