Re: [PATCH v3 1/8] t7519: rewrite sparse index test
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Aug 20, 2021, 16:40 UTC
- Message-ID
- <CAPig+cQM35GXQ_2ghi+c7zDOaNx3_ryCOCuXq7ib4Ej+fUeMEA@mail.gmail.com>
- In-Reply-To
- <24b1b932-caf9-b709-baf4-a2f8669deb88@gmail.com>
On Fri, Aug 20, 2021 at 11:09 AM Derrick Stolee <stolee@gmail.com> wrote:
Show 7 quoted lines
> On 8/19/2021 3:45 AM, Johannes Schindelin wrote:> On Tue, 17 Aug 2021, Derrick Stolee via GitGitGadget wrote: > >> + write_script .git/hooks/fsmonitor-test <<-\EOF && > >> printf "last_update_token\0" > > > > Technically, the backslash needs to be escaped because it is within double > > quotes and we do not want the shell to interpolate the `\0`, but `printf`. > > Practically, all the shells I tried handle this as expected.
Technically, for a POSIX-conforming shell, `\0` is correct, and the backslash does not need to be escaped. Of course, it doesn't hurt to write `\\0` since it resolves to the same thing, but it isn't necessary. See POSIX section "2.2.3 Double-Quotes": https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02_03
Show 6 quoted lines
> I have no opinions on this one way or another. I will just point out that > the pattern used in this test is also used throughout the test script, so > any change to that format should be applied universally. The test has been > operating without complaint since it was introduced in 5c8cdcf (fsmonitor: > add test cases for fsmonitor extension, 2017-09-22), so compatibility is > likely not a problem.
Since POSIX says that `\0` is correct and since we haven't encountered any shells which handle this incorrectly, there seems little reason to change it.