Re: [PATCH v6 01/15] help: move list_config_help to builtin/help
- From
Emily Shaffer <emilyshaffer@google.com>
- Date
- Feb 13, 2020, 22:58 UTC
- Message-ID
- <20200213225834.GI190927@google.com>
- In-Reply-To
- <20200206013533.GA3993@danh.dev>
On Thu, Feb 06, 2020 at 08:35:33AM +0700, Danh Doan wrote:
Show 79 quoted lines
> On 2020-02-05 16:40:54-0800, Emily Shaffer <emilyshaffer@google.com> wrote:
> > diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
> > index 71158f7d8b..45fecf8bdf 100755
> > --- a/generate-cmdlist.sh
> > +++ b/generate-cmdlist.sh
> > @@ -76,23 +76,6 @@ print_command_list () {
> > echo "};"
> > }
> >
> > -print_config_list () {
> > - cat <<EOF
> > -static const char *config_name_list[] = {
> > -EOF
> > - grep -h '^[a-zA-Z].*\..*::$' Documentation/*config.txt Documentation/config/*.txt |
> > - sed '/deprecated/d; s/::$//; s/, */\n/g' |
> > - sort |
> > - while read line
> > - do
> > - echo " \"$line\","
> > - done
> > - cat <<EOF
> > - NULL,
> > -};
> > -EOF
> > -}
> > -
> > exclude_programs=
> > while test "--exclude-program" = "$1"
> > do
> > @@ -113,5 +96,3 @@ echo
> > define_category_names "$1"
> > echo
> > print_command_list "$1"
> > -echo
> > -print_config_list
> > diff --git a/generate-configlist.sh b/generate-configlist.sh
> > new file mode 100755
> > index 0000000000..eca6a00c30
> > --- /dev/null
> > +++ b/generate-configlist.sh
> > @@ -0,0 +1,24 @@
> > +#!/bin/sh
> > +
> > +echo "/* Automatically generated by generate-configlist.sh */"
> > +echo
> > +
> > +print_config_list () {
> > + cat <<EOF
> > +static const char *config_name_list[] = {
> > +EOF
> > + grep -h '^[a-zA-Z].*\..*::$' Documentation/*config.txt Documentation/config/*.txt |
> > + sed '/deprecated/d; s/::$//; s/, */\n/g' |
> > + sort |
> > + while read line
> > + do
> > + echo " \"$line\","
> > + done
>
> This while-read-echo was moved from generate-cmdlist.sh,
> which has some logic to work with read-variable.
>
> We're moving it out, I think apply this diff on top of it will make the code easier to read.
>
> diff --git a/generate-configlist.sh b/generate-configlist.sh
> index eca6a00c30..163dbf30bb 100755
> --- a/generate-configlist.sh
> +++ b/generate-configlist.sh
> @@ -10,10 +10,7 @@ EOF
> grep -h '^[a-zA-Z].*\..*::$' Documentation/*config.txt Documentation/config/*.txt |
> sed '/deprecated/d; s/::$//; s/, */\n/g' |
> sort |
> - while read line
> - do
> - echo " \"$line\","
> - done
> + sed 's/^/ "/; s/$/",/'
> cat <<EOF
> NULL,
> };Thanks for the suggestion. You're right that I didn't look into the contents of this script much, because I was just moving it; I modified your sed expression slightly so it performs just one operation:
sed 's/^.*$/ "\0",/'
- Emily