On 16/04/18 16:43, SZEDER Gábor wrote:
> On Sun, Apr 15, 2018 at 6:42 PM, Nguyễn Thái Ngọc Duy <[email protected]>
> 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 <[email protected]>
>> ---
>> 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