Re: [PATCH v6 00/11] Fix icase grep on non-ascii
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 22, 2016, 18:59 UTC
- Message-ID
- <CAPc5daU4K85a883sR0u87fTObakCvv6Z41qxx1WOT2=QdDjZeA@mail.gmail.com>
- In-Reply-To
- <CACsJy8BMCjjX7_d73LX8+SiYWA4UUFyU3GGzxSVXMK4xubsKNg@mail.gmail.com>
On Wed, Jun 22, 2016 at 11:41 AM, Duy Nguyen <pclouds@gmail.com> wrote:
Show 25 quoted lines
> On Wed, Jun 22, 2016 at 8:36 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> On Wed, Jun 22, 2016 at 11:29 AM, Duy Nguyen <pclouds@gmail.com> wrote:
>>>
>>> Can any shell wizards explain this to me? With this code
>>>
>>> BS=\\
>>> echo ${BS}${BS}
>>>
>>> Debian's dash returns a single backslash while bash returns two
>>> backslashes. Section 2.2.1 [1] does not say anything about one
>>> backslash (hidden behind a variable!) after escaping the following one
>>> and still eats the one after that..
>>>
>>> [1] http://pubs.opengroup.org/onlinepubs/009604499/utilities/xcu_chap02.html
>>
>> I am not a wizard, but is the difference between the shell syntax, or just their
>> implementation of builtin-echo? IOW, how do these three compare?
>>
>> printf "%s\n" "${BS}${BS}"
>> echo "${BS}${BS}"
>> echo ${BS}$BS}
>
> Great! printf shows two backslashes while both echo'es show one.
> printf "\\\\" behaves like echo though. Doesn't matter, at least I
> should be able to make the tests work on Debian dash.I think somebody's implementation of "echo" is not POSIX kosher. According to
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html
you should expect a single backslash. If a script depends on seeing two, the script is buggy.