Re: [PATCH v12 1/5] t0040-test-parse-options.sh: fix style issues

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

 



On Mon, Apr 4, 2016 at 8:45 AM, Pranit Bauva <pranit.bauva@xxxxxxxxx> wrote:
> Okay I will do the change. I was previously unaware about the use of
> '\' before EOF. I googled it now. But I am still confused about its
> use in this scenario. Upto what I understood, it is used where you
> want to expand a variable, substitute a command, arithmethic
> expansion. The use of '\' in the tests I have changed in v12 wrt 11 is
> understood by me as you want to remove the use of escape sequences
> which is justified. But this seems a bit vague. Is it some convention
> in git?

Both 'EOF' and \EOF suppress interpolation and other transformations
in the heredoc content which would otherwise occur with plain EOF. The
'EOF' form is well documented; \EOF not so much, but is used heavily
in git test scripts. So:

    x=flormp
    echo <<EOF
    Hello, $x
    EOF

prints "Hello, flormp", whereas:

    echo <<\EOF
    Hello, $x
    EOF

prints "Hello, $x".

While test scripts sometimes use \EOF to explicitly suppress variable
expansion, it's also quite common to use it even when there is nothing
which could be expanded in the heredoc content, in which case it
signals to the reader that the author doesn't expect the content to
undergo expansion or interpolation. It's also a bit of future-proofing
in case some later change to the heredoc content inserts something
which might otherwise be expanded.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



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