[systemd-devel] [PATCH] bash-completion: --property support

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Tue Apr 16 19:10:27 PDT 2013


On Tue, Apr 16, 2013 at 01:57:47PM -0400, Dave Reisner wrote:
> On Tue, Apr 16, 2013 at 01:48:14PM -0400, Zbigniew Jędrzejewski-Szmek wrote:
> > ---
> > It turns out that simply fetching the list is fast enough.
> > At least on my relatively beefy machine. And this approach
> > is quite easy. So I think we can do that.
> >
> > Zbyszek
> >
> >  shell-completion/bash/systemctl | 25 ++++++++++++++++++-------
> >  1 file changed, 18 insertions(+), 7 deletions(-)
> >
> > diff --git a/shell-completion/bash/systemctl b/shell-completion/bash/systemctl
> > index f24a145..2c004d9 100644
> > --- a/shell-completion/bash/systemctl
> > +++ b/shell-completion/bash/systemctl
> > @@ -22,6 +22,17 @@ __systemctl() {
> >          systemctl $mode --full --no-legend "$@"
> >  }
> >
> > +__systemd_properties() {
> > +        local mode=$1; shift 1
> 
> The shift seems superfluous here -- you never reference any positional
> params in this function.
> 
> > +        { __systemctl $mode show;
> > +         systemd --dump-configuration-items; } |
> > +        while read -r line; do
> > +            if [[ "$line" =~ .*= ]]; then
> > +                echo ${line%%=*}
> > +            fi
> 
> I'd skip the regex and just split in the while loop:
> 
>   while IFS='=' read -r key value; do
>     [[ $value ]] && echo "$key"
>   done
Thanks. I'll apply the patch with your suggestions.

Zbyszek


More information about the systemd-devel mailing list