Re: [PATCH v2 8/8] hook-list.h: add a generated list of hooks, like config-list.h
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 27, 2021, 20:23 UTC
- Message-ID
- <xmqqk0j1py2a.fsf@gitster.g>
- In-Reply-To
- <0e07cee4-079a-af12-880f-d4a99300df28@web.de>
René Scharfe <l.s.r@web.de> writes:
Show 33 quoted lines
> Am 27.09.21 um 18:48 schrieb Junio C Hamano:
>> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>>
>>> +sed -n \
>>> + -e '/^~~~~*$/ {x; s/^.*$/ "&",/; p;}' \
>>> + -e 'x' \
>>> + <Documentation/githooks.txt |
>>> + LC_ALL=C sort
>>
>> Thanks. It is not wrong per-se, but if you are willing to do a
>> multi-line script for readability, wouldn't a much more readable
>> "single long and multi-line string" approach, i.e.
>>
>> sed -ne '
>> /^~~~~*$/ {
>> x
>> s/^.*$/ "&",/
>> p
>> }
>> x
>> ' Documentation/githooks.txt |
>> LC_ALL=C sort
>>
>> work better?
>>
>
> It is more readable, but according to OpenBSD's sed(1) manpage it would
> also be non-portable (https://man.openbsd.org/sed#STANDARDS). That note
> was added in 2006 (https://github.com/openbsd/src/commit/24ce9718),
> though, so perhaps it needs an update.
>
> FWIW, generate-cmdlist.sh uses such a multi-line sed script in its
> function get_synopsis.I wonder who wrote the invocation in generate-cmdlist.sh ;-)
FWIW, the informative part of POSIX.1 sed manpage
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html#tag_20_116_17
has such a single long and multi-line string script given on the command line, but "non-portable" can refer to "some implementations may not implement all of what POSIX expects", so ... ;-)