Re: [PATCH v2 3/6] generate-cmdlist.sh: keep all information in common-cmds.h
- From
SZEDER Gábor <szeder.dev@gmail.com>
- Date
- Apr 16, 2018, 15:43 UTC
- Message-ID
- <CAM0VKjkns+AsVyMSe2fxzT8a8oqYdNX3qO8mnw2juOgFC7LHYA@mail.gmail.com>
- 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 <pclouds@gmail.com> wrote:
Show 16 quoted lines
> 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
Show 11 quoted lines
> -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.