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]

 



Hi Ævar,

On Tue, Feb 7, 2023 at 3:12 AM Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> 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!

------
Shuqi




[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