From cb6147ccd181a606628089a4222d933ed6145e9c Mon Sep 17 00:00:00 2001 From: John Southworth Date: Fri, 29 Jul 2011 20:39:22 -0700 Subject: Bugfix 2823: Operational mode command interpreter --- etc/bash_completion.d/vyatta-op | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'etc/bash_completion.d/vyatta-op') diff --git a/etc/bash_completion.d/vyatta-op b/etc/bash_completion.d/vyatta-op index 5ac807e..7d6ddb5 100644 --- a/etc/bash_completion.d/vyatta-op +++ b/etc/bash_completion.d/vyatta-op @@ -101,18 +101,23 @@ _vyatta_op_init () complete -E -F _vyatta_op_expand complete -D -F _vyatta_op_default_expand - for xd in $vyatta_op_templates/* ; do - if [ -d $xd ] ; then - cmd=${xd##*/} - complete -F _vyatta_op_expand $cmd - eval alias $cmd=\'_vyatta_op_run $cmd\' - fi + # create the top level aliases for the unambiguous portions of the commands + # this is the only place we need an entire enumerated list of the subcommands + for cmd in $( ls /opt/vyatta/share/vyatta-op/templates/ ); do + for pos in $(seq 1 ${#cmd}); do + case ${cmd:0:$pos} in + for|do|done|if|fi|case|while|tr ) + continue ;; + *) ;; + esac + complete -F _vyatta_op_expand ${cmd:0:$pos} + eval alias ${cmd:0:$pos}=\'_vyatta_op_run ${cmd:0:$pos}\' + done done shopt -s histverify } - # $1: label # $2...: help _vyatta_op_print_help () @@ -177,10 +182,13 @@ _vyatta_op_help () _vyatta_op_set_node_path () { + local node _vyatta_op_node_path=$vyatta_op_templates for (( i=0 ; i