diff options
author | Tom Grennan <tgrennan@vyatta.com> | 2007-11-28 12:00:19 -0800 |
---|---|---|
committer | Tom Grennan <tgrennan@vyatta.com> | 2007-11-28 12:00:19 -0800 |
commit | a152d776031a0b5cb77b7c57c40d7c2753e2edaa (patch) | |
tree | bec9304306d9293d8267808491c008caf6adb6ca /etc/bash_completion.d | |
parent | 403910599a5861ff7d98415439ea85e45afd4bed (diff) | |
download | vyatta-op-a152d776031a0b5cb77b7c57c40d7c2753e2edaa.tar.gz vyatta-op-a152d776031a0b5cb77b7c57c40d7c2753e2edaa.zip |
donot complete "<*>" allowed values; instead just list in help
Diffstat (limited to 'etc/bash_completion.d')
-rw-r--r-- | etc/bash_completion.d/10vyatta-op | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/etc/bash_completion.d/10vyatta-op b/etc/bash_completion.d/10vyatta-op index c698027..7aa29a3 100644 --- a/etc/bash_completion.d/10vyatta-op +++ b/etc/bash_completion.d/10vyatta-op @@ -43,6 +43,13 @@ _vyatta_op_debug () _vyatta_op_init () { + local restore_shopts=$( shopt -p nullglob | tr \\n \; ) + shopt -s nullglob + for f in ${vyatta_datadir}/vyatta-op/functions/allowed/* ; do + source $f + done + eval $restore_shopts + complete -F _vyatta_op_expand '' for xd in $vyatta_op_templates/* ; do @@ -147,8 +154,18 @@ _vyatta_op_help () _vyatta_op_compreply () { local cur=$1; shift + local -a comps justhelp + + # donot complete entries like <HOSTNAME> or <A.B.C.D> + for allow ; do + if [[ "$allow" == \<*\> ]] ; then + justhelp+=( $allow ) + else + comps+=( $allow ) + fi + done - COMPREPLY=($( compgen -W "$*" -- $cur )) + COMPREPLY=($( compgen -W "${comps[*]}" -- $cur )) # if the last command line arg is empty and we have # an empty completion option (meaning wild card), @@ -166,7 +183,9 @@ _vyatta_op_compreply () fi if [ "${COMP_WORDS[*]}" == "$_vyatta_op_last_comp" ] ; then - _vyatta_op_help "$cur" "$node_path" "${comps[@]}" + _vyatta_op_help "$cur" "$node_path" \ + ${justhelp[@]} \ + $(printf "%s\n" ${comps[@]} | sort) COMPREPLY=( "" " " ) _vyatta_op_last_comp="" else @@ -183,7 +202,7 @@ _vyatta_op_expand () (( COMP_CWORD = ${#COMP_WORDS[@]} )) fi local node_path=$vyatta_op_templates - local -a comps + local -a allowed local restore_shopts=$( shopt -p extglob nullglob | tr \\n \; ) shopt -s extglob nullglob @@ -204,17 +223,17 @@ _vyatta_op_expand () local acmd=$( _vyatta_op_get_node_def_field $ndef allowed ) local -a a=($( eval "$acmd" )) if [ ${#a[@]} -ne 0 ] ; then - comps+=( "${a[@]}" ) + allowed+=( "${a[@]}" ) else - comps+=( "" ) + allowed+=( "" ) fi else local sdir=${ndef%/*} - comps+=( ${sdir##*/} ) + allowed+=( ${sdir##*/} ) fi done - _vyatta_op_compreply "$cur" "${comps[@]}" + _vyatta_op_compreply "$cur" "${allowed[@]}" eval $restore_shopts } |