From: SZEDER Gábor Date: Mon, 16 Apr 2018 15:43:09 GMT Subject: Re: [PATCH v2 3/6] generate-cmdlist.sh: keep all information in common-cmds.h Message-ID: In-Reply-To: <20180415164238.9107-4-pclouds@gmail.com> On Sun, Apr 15, 2018 at 6:42 PM, Nguyễn Thái Ngọc Duy 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 > --- > 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.