Stefan Beller wrote:
> On Wed, Mar 22, 2017 at 2:59 PM, Jeff King <[email protected]> wrote:
>> sq=\'
>> test_expect_success '...' '
>> cat >expect <<-EOF
>> Execution of ${sq}false $submodulesha1${sq} ...
>> '
>>
>> but I'm not sure if that is any more readable.
>
> If I recall correctly, I made a big fuss about single quotes used correctly
> when
> writing that patch (which is why I may have lost track of the actual work
> there)
> to be told the one and only blessed way to use single quotes in our test
> suite.
>
> Your proposal to use ${sq} sounds good to me, though we did not
> follow through with it for some other reason. I can reroll with that, though.
I don't know what you're referring to by only and blessed way, but it
might be the following. If you want to use single-quotes on a command
line using $sq, you would have to use eval:
eval "some_command ${sq}single-quoted argument${sq}"
which is generally more complicated than doing the '\'' dance:
some_command '\''single-quoted argument'\''
But the example in this thread is different. In the here-document you
are in an interpolated context so the ${sq} method or '\'' would work
equally well.
Hope that helps,
Jonathan