[arch-projects] [netctl] [PATCH] Fix bash completion for profiles names.

Jouke Witteveen j.witteveen at gmail.com
Wed Nov 2 13:27:40 UTC 2016


Thanks! I'll make sure this ends up in the next version, which is
currently held back by
https://github.com/systemd/systemd/pull/4259


On Fri, Oct 28, 2016 at 12:22 AM, Romain Aigron
<aigron.romain at wanadoo.fr> wrote:
> This patch fixes completion for the netctl and netctl_auto
> commands for profiles names, treating them as filenames.
> This allow proper completion for profiles with spaces or quotes in their
> name (as it happends for instance with wifi-menu's autogenerated profile
> names)
>
> Signed-off-by: Romain Aigron <aigron.romain at wanadoo.fr>
> ---
>  contrib/bash-completion | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/contrib/bash-completion b/contrib/bash-completion
> index 2ab6acb..5778e84 100644
> --- a/contrib/bash-completion
> +++ b/contrib/bash-completion
> @@ -13,7 +13,9 @@ _wireless_interfaces()
>
>  _netctl_profiles()
>  {
> -    find -L /etc/netctl -maxdepth 1 -type f -not -name '.*' -not -name '*~' -not -name '*.conf' -not -name '*.service' -printf "%f\n"
> +    local profile
> +    find -L /etc/netctl -maxdepth 1 -type f -not -name '.*' -not -name '*~' -not -name '*.conf' -not -name '*.service' -printf "%f\n" |
> +      while read -r profile; do quote_readline "$profile"; echo; done
>  }
>
>
> @@ -27,6 +29,7 @@ _netctl()
>        ;;
>        2)
>          [[ ${COMP_WORDS[COMP_CWORD-1]} = @(start|stop|restart|switch-to|is-active|status|enable|disable|reenable|is-enabled|edit) ]] &&
> +          compopt -o filenames &&
>            mapfile -t COMPREPLY < <(IFS=$'\n'; compgen -W "$(_netctl_profiles)" -- "$cur")
>        ;;
>      esac
> @@ -44,6 +47,7 @@ _netctl_auto()
>        ;;
>        2)
>          [[ ${COMP_WORDS[COMP_CWORD-1]} = @(switch-to|is-active|enable|disable|is-enabled) ]] &&
> +          compopt -o filenames &&
>            mapfile -t COMPREPLY < <(IFS=$'\n'; compgen -W "$(_netctl_profiles)" -- "$cur")
>        ;;
>      esac
> --
> 2.10.0


More information about the arch-projects mailing list