diff options
author | John Southworth <john.southworth@vyatta.com> | 2011-10-11 11:27:57 -0500 |
---|---|---|
committer | John Southworth <john.southworth@vyatta.com> | 2011-10-11 11:27:57 -0500 |
commit | 032557e0f916327c5ca59aa7477d5867112d174e (patch) | |
tree | 0c7554cefa13770657e6b659046aa3068e824268 | |
parent | 52974c19b9d171d957ddec1293380b457732e743 (diff) | |
download | vyatta-cfg-032557e0f916327c5ca59aa7477d5867112d174e.tar.gz vyatta-cfg-032557e0f916327c5ca59aa7477d5867112d174e.zip |
Fix completions for fields that have more than one word
* Make the compreply filter not sort a list that contains only one
element. This can cause some problems because some elements contain
multiple words, interface descriptions for instance.
* Fix typo in function name
-rwxr-xr-x | etc/bash_completion.d/vyatta-cfg | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/etc/bash_completion.d/vyatta-cfg b/etc/bash_completion.d/vyatta-cfg index 96cc555..aada483 100755 --- a/etc/bash_completion.d/vyatta-cfg +++ b/etc/bash_completion.d/vyatta-cfg @@ -137,7 +137,7 @@ vyatta_run_complete () if [ -z "$comp" ] ; then if [ ${#COMPREPLY[@]} -eq 0 ] ; then COMPREPLY=( " " "" ) - elif _vyatta_op_comprely_needs_ambiguity ; then + elif _vyatta_cfg_compreply_needs_ambiguity ; then COMPREPLY+=( " " ) fi fi @@ -569,7 +569,7 @@ vyatta_do_complete () if [ -z "$comp" ] ; then if [ ${#COMPREPLY[@]} -eq 0 ] ; then COMPREPLY=( " " "" ) - elif _vyatta_op_comprely_needs_ambiguity ; then + elif _vyatta_cfg_compreply_needs_ambiguity ; then COMPREPLY+=( " " ) fi fi @@ -595,13 +595,13 @@ vyatta_do_complete () vyatta_help_text="\\nNo help text available" } -_vyatta_cfg_comprely_needs_ambiguity () +_vyatta_cfg_compreply_needs_ambiguity () { local -a uniq [ ${#COMPREPLY[@]} -eq 1 ] && return - uniq=( `printf "%s\n" ${COMPREPLY[@]} | cut -c1 | sort -u` ) + uniq=( `printf "%s\n" "${COMPREPLY[@]}" | cut -c1 | sort -u` ) [ ${#uniq[@]} -eq 1 ] && return false @@ -619,7 +619,9 @@ vyatta_simple_complete () local cur=${COMP_WORDS[COMP_CWORD]} local -a f_comps=() get_prefix_filtered_list "$current_prefix" vyatta_completions f_comps - f_comps=( $(printf "%s\n" "${vyatta_completions[@]}" | sort -u) ) + if [[ ${#f_comps[@]} -ne 1 ]]; then + f_comps=( $(printf "%s\n" "${f_comps[@]}" | sort -u) ) + fi COMPREPLY=( "${f_comps[@]}" ) @@ -633,7 +635,7 @@ vyatta_simple_complete () if [ -z "$comp" ] ; then if [ ${#COMPREPLY[@]} -eq 0 ] ; then COMPREPLY=( " " "" ) - elif _vyatta_op_comprely_needs_ambiguity ; then + elif _vyatta_cfg_compreply_needs_ambiguity ; then COMPREPLY+=( " " ) fi fi |