diff options
author | John Southworth <john.southworth@vyatta.com> | 2011-10-06 10:51:32 -0500 |
---|---|---|
committer | John Southworth <john.southworth@vyatta.com> | 2011-10-06 10:51:59 -0500 |
commit | 556e70adc3b8b2e3dff5a8e1d217e740bd240505 (patch) | |
tree | 1e41963229111f4292523be73b6bc00160c5509c /etc | |
parent | f84e141ecbd45a6b2b08d97241be05b2ef0935a4 (diff) | |
download | vyatta-op-556e70adc3b8b2e3dff5a8e1d217e740bd240505.tar.gz vyatta-op-556e70adc3b8b2e3dff5a8e1d217e740bd240505.zip |
Make operational mode completion when the user enters an unknown prefix on a tag node consistent with configuration mode
Diffstat (limited to 'etc')
-rw-r--r-- | etc/bash_completion.d/vyatta-op | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/etc/bash_completion.d/vyatta-op b/etc/bash_completion.d/vyatta-op index 19f2519..48074dd 100644 --- a/etc/bash_completion.d/vyatta-op +++ b/etc/bash_completion.d/vyatta-op @@ -147,6 +147,10 @@ _vyatta_op_help () if [ -z "$cur" -a -n "$node_run" ]; then _vyatta_op_print_help '<Enter>' "Execute the current command" fi + if [ $# -eq 0 ];then + _vyatta_op_print_help '<text>' "$node_tag_help" + return + fi for comp ; do if [[ "$comp" == "<Enter>" ]]; then continue @@ -276,14 +280,14 @@ _vyatta_op_invalid_completion () arg=( $(_vyatta_op_conv_node_path $tpath $arg) ) # expand the arguments # output proper error message based on the above expansion if [[ "${arg[1]}" == "ambiguous" ]]; then - echo -ne "\n Ambiguous command: ${args[@]} [$arg]\n" + echo -ne "\n\n Ambiguous command: ${args[@]} [$arg]\n" local -a cmds=( "$tpath/$arg"* ) _vyatta_op_node_path=$tpath local comps=$(_vyatta_op_help $arg ${cmds[@]##*/}) echo -ne "$comps" | sed -e 's/^P/ P/' break elif [[ "${arg[1]}" == "invalid" ]]; then - echo -ne "\n Invalid command: ${args[@]} [$arg]" + echo -ne "\n\n Invalid command: ${args[@]} [$arg]" break fi @@ -292,13 +296,16 @@ _vyatta_op_invalid_completion () elif [ -f $tpath/node.tag/node.def ] ; then tpath+=/node.tag else - echo -ne "\n Invalid command: ${args[@]} [$arg]" >&2 + echo -ne "\n\n Invalid command: ${args[@]} [$arg]" >&2 break fi args[$i]=$arg let "i+=1" if [ $[${#COMP_WORDS[@]}+1] -eq $i ];then - echo -ne "\n No completion found with prefix [$arg]" + _vyatta_op_help "" \ + ${_vyatta_op_noncompletions[@]} \ + ${_vyatta_op_completions[@]} \ + | ${VYATTA_PAGER:-cat} fi done } @@ -344,7 +351,7 @@ _vyatta_op_expand () # this will lead to unexpected cases if setting the node path isn't attempted # each time. if ! _vyatta_op_set_node_path ; then - echo -e \\a + echo -ne \\a _vyatta_op_invalid_completion COMPREPLY=( "" " " ) eval "$restore_shopts" @@ -412,13 +419,11 @@ _vyatta_op_expand () # if there are no completions then handle invalid commands if [ ${#_vyatta_op_noncompletions[@]} -eq 0 ] && [ ${#_vyatta_op_completions[@]} -eq 0 ]; then - echo _vyatta_op_invalid_completion COMPREPLY=( "" " " ) _vyatta_op_last_comp=${_vyatta_op_last_comp_init} elif [ ${#COMPREPLY[@]} -eq 0 ] && [ -n "$current_prefix" ]; then - echo _vyatta_op_invalid_completion COMPREPLY=( "" " " ) _vyatta_op_last_comp=${_vyatta_op_last_comp_init} |