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 23, 2018, 09:59 UTC
- Message-ID
- <20180423095927.2077-1-szeder.dev@gmail.com>
- In-Reply-To
- <20180423082318.27314-1-oystwa@gmail.com>
Show 21 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>
> > Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
> >
> > > +category_list () {
> > > + command_list "$1" | awk '{print $2;}' | sort | uniq
> > > +}
> >
> > Piping output of awk to sort/uniq, instead of processing all inside
> > awk within the END block of the script, means that we are wasting
> > two processes---I do not think we care too much about it, but some
> > people might.
> >
>
> Can be written as:
>
> command_list "$1" | awk '!seen[$2]++ {print $2}'
>
> This doesn't actually sort it, though, which I'm not sure whether is a
> good thing or a bad thing in this case. But it is less work, and being fast is
> nice for completion scripts.This script is run during the build process, not during completion.
(The order wouldn't matter for completion, because the shell would sort possible completion words anyway.)