Re: [PATCH v2 3/6] generate-cmdlist.sh: keep all information in common-cmds.h
- From
Ramsay Jones <ramsay@ramsayjones.plus.com>
- Date
- Apr 16, 2018, 16:25 UTC
- Message-ID
- <9f5d2533-1012-aaf6-2703-88525236800f@ramsayjones.plus.com>
- In-Reply-To
- <CAM0VKjkns+AsVyMSe2fxzT8a8oqYdNX3qO8mnw2juOgFC7LHYA@mail.gmail.com>
On 16/04/18 16:43, SZEDER Gábor wrote:
Show 40 quoted lines
> On Sun, Apr 15, 2018 at 6:42 PM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
>> common-cmds.h is used to extract the list of common commands (by
>> group) and a one-line summary of each command. Some information is
>> dropped, for example command category or summary of other commands.
>> Update generate-cmdlist.sh to keep all the information. The extra info
>> will be used shortly.
>>
>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
>> ---
>> generate-cmdlist.sh | 61 +++++++++++++++++++++++++++++++++------------
>> help.c | 42 ++++++++++++++++++++++++++-----
>> 2 files changed, 81 insertions(+), 22 deletions(-)
>>
>> diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
>> index eeea4b67ea..e0893e979a 100755
>> --- a/generate-cmdlist.sh
>> +++ b/generate-cmdlist.sh
>
>> -printf 'static struct cmdname_help common_cmds[] = {\n'
>> -grep -f "$match" "$1" |
>> -sed 's/^git-//' |
>> +printf 'static struct cmdname_help command_list[] = {\n'
>> +command_list "$1" |
>> sort |
>> -while read cmd tags
>> +while read cmd category tags
>> do
>> - tag=$(echo "$tags" | sed "$substnum; s/[^0-9]//g")
>> + name=${cmd/git-}
>
> There are two issues with this line:
>
> - This is a "regular" shell script, therefore it must not use pattern
> substitution.
>
> - The pattern substitution would remove the string "git-" in the middle of
> the variable as well; I suspect this is undesired.
>
> I think that the remove matching prefix pattern substitution should be
> used here.This also, apparently, doesn't work with dash. On cygwin, which has bash as /bin/sh, this builds common-cmds.h just fine. On linux, which has dash as /bin/sh, this fails, leaving a truncated file:
$ bash generate-cmdlist.sh command-list.txt >zzz
$ tail -3 zzz
{"gitweb", N_("Git web interface (web frontend to Git repositories)"), CAT_ancillaryinterrogators, GROUP_NONE },
{"workflows", N_("An overview of recommended workflows with Git"), CAT_guide, GROUP_NONE },
};$ dash generate-cmdlist.sh command-list.txt >zzz generate-cmdlist.sh: 73: generate-cmdlist.sh: Bad substitution $ tail -3 zzz
static struct cmdname_help command_list[] = {
};
$ This leads to a very broken 'git help'.
ATB, Ramsay Jones