On 05/07/2015 03:45 PM, Gabriel Krisman Bertazi wrote:
> Introduce an autocomplete system for iprconfig in bash.  Provide
> completion for devices and iprconfig commands, depending on the current
> context.

I can't seem to get this patch to work. I noticed if I compile manually
just by doing make install, it installs iprconfig-bash-completion.sh
in /usr/local/etc/bash_completion.d/. I then manually copied 
iprconfig-bash-completion.sh
to /etc/bash_completion.d/, and it still didn't seem to do anything.
Tried doing exec bash first, even logged out and logged back in.

Am I missing something here? iprconfig -l seems to do the right thing...

-Brian


> 
> Signed-off-by: Gabriel Krisman Bertazi <kris...@linux.vnet.ibm.com>
> ---
>  Makefile.am                  |  3 +++
>  iprconfig-bash-completion.sh | 29 +++++++++++++++++++++++++++++
>  iprconfig.c                  | 11 +++++++++++
>  spec/iprutils.spec           |  1 +
>  4 files changed, 44 insertions(+)
>  create mode 100644 iprconfig-bash-completion.sh
> 
> diff --git a/Makefile.am b/Makefile.am
> index daae8e5..dd98fe2 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -31,6 +31,9 @@ iprdbg_LDADD= libipr.la
> 
>  dist_man_MANS = iprconfig.8 iprdump.8 iprinit.8 iprupdate.8 iprsos.8
> 
> +bashcompdir = ${sysconfdir}/bash_completion.d
> +dist_bashcomp_DATA = iprconfig-bash-completion.sh
> +
>  SUBDIRS = . systemd init.d spec
> 
>  sosreportdir = @pythondir@/sos/plugins
> diff --git a/iprconfig-bash-completion.sh b/iprconfig-bash-completion.sh
> new file mode 100644
> index 0000000..9ede9b7
> --- /dev/null
> +++ b/iprconfig-bash-completion.sh
> @@ -0,0 +1,29 @@
> +#  IBM IPR adapter configuration utility
> +#
> +#  (C) Copyright 2000, 2015
> +#  International Business Machines Corporation and others.
> +#  All Rights Reserved. This program and the accompanying
> +#  materials are made available under the terms of the
> +#  Common Public License v1.0 which accompanies this distribution.
> +
> +_comp_iprconfig () {
> +    iprconfig="${COMP_WORDS[0]}"
> +    cur="${COMP_WORDS[COMP_CWORD]}"
> +    prev="${COMP_WORDS[COMP_CWORD-1]}"
> +
> +    case "${prev}" in
> +     "-c")
> +         opts=$(${iprconfig} -l 2>/dev/null)
> +         COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
> +         ;;
> +     "-k")
> +         COMPREPLY=( $(compgen -o dirnames -- ${cur}) )
> +         ;;
> +     *)
> +         opts=$(find /dev -printf "%f\n" | grep -G "^\(sd\|sg\)")
> +         COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
> +         ;;
> +    esac
> +    return 0;
> +}
> +complete -F _comp_iprconfig iprconfig
> diff --git a/iprconfig.c b/iprconfig.c
> index 9fae41a..55b8289 100644
> --- a/iprconfig.c
> +++ b/iprconfig.c
> @@ -18463,6 +18463,13 @@ int check_sg_module()
>       return 0;
>  }
> 
> +void list_options()
> +{
> +     int i;
> +     for (i = 0; i < ARRAY_SIZE(command); i++)
> +             printf ("%s\n", command[i].cmd);
> +}
> +
>  /**
>   * main - program entry point
>   * @argc:            number of arguments
> @@ -18500,6 +18507,10 @@ int main(int argc, char *argv[])
>                               next_dir = 1;
>                       else if (strcmp(argv[i], "-c") == 0)
>                               next_cmd = 1;
> +                     else if (strcmp(argv[i], "-l") == 0) {
> +                             list_options();
> +                             exit(1);
> +                     }
>                       else if (next_editor)   {
>                               strcpy(parm_editor, argv[i]);
>                               next_editor = 0;
> diff --git a/spec/iprutils.spec b/spec/iprutils.spec
> index c3af8c3..0a69d29 100644
> --- a/spec/iprutils.spec
> +++ b/spec/iprutils.spec
> @@ -134,6 +134,7 @@ rm -rf %{_topdir}/BUILD%{name}
>  %{_sysconfdir}/ha.d
>  %{_sysconfdir}/ha.d/resource.d
>  %{_sysconfdir}/ha.d/resource.d/iprha
> +%{_sysconfdir}/bash_completion.d/*
>  %if %{?_unitdir:1}%{!?_unitdir:0}
>       %{_unitdir}/*
>  %else
> 


-- 
Brian King
Power Linux I/O
IBM Linux Technology Center



------------------------------------------------------------------------------
_______________________________________________
Iprdd-devel mailing list
Iprdd-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iprdd-devel

Reply via email to