From b74a46d1c13446aeca6709ccea3ce093069f4eb9 Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Fri, 1 Feb 2008 16:50:54 -0800 Subject: fix for bug 2616: implement "up" and "top" in configure mode. --- etc/bash_completion.d/20vyatta-cfg | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'etc') diff --git a/etc/bash_completion.d/20vyatta-cfg b/etc/bash_completion.d/20vyatta-cfg index 4a4eb18..00482c5 100644 --- a/etc/bash_completion.d/20vyatta-cfg +++ b/etc/bash_completion.d/20vyatta-cfg @@ -38,7 +38,7 @@ declare -a comp_words=() # commands to unalias declare -a unalias_cmds=( clear configure date debug edit exit load \ - no run set show save terminal undebug ) + no run set show save terminal undebug up top ) for cmd in "${unalias_cmds[@]}"; do unalias $cmd >& /dev/null done @@ -93,6 +93,19 @@ load () eval "${vyatta_sbindir}/vyatta-load-config.pl $@" } +top () +{ + if [ "$VYATTA_EDIT_LEVEL" == "/" ]; then + echo "Already at the top level" + return 0 + fi + + # go to the top level. + export VYATTA_EDIT_LEVEL="/" + export VYATTA_TEMPLATE_LEVEL="/" + set_config_ps1 '' +} + edit () { local num_comp=${#@} @@ -158,6 +171,26 @@ edit () set_config_ps1 "$path_str" } +up () +{ + if [ "$VYATTA_EDIT_LEVEL" == "/" ]; then + echo "Already at the top level" + return 0 + fi + if [[ $VYATTA_TEMPLATE_LEVEL == */node.tag/ ]]; then + export VYATTA_EDIT_LEVEL="${VYATTA_EDIT_LEVEL%/*/*/}/" + export VYATTA_TEMPLATE_LEVEL="${VYATTA_TEMPLATE_LEVEL%/*/*/}/" + else + export VYATTA_EDIT_LEVEL="${VYATTA_EDIT_LEVEL%/*/}/" + export VYATTA_TEMPLATE_LEVEL="${VYATTA_TEMPLATE_LEVEL%/*/}/" + fi + + declare -a path_arr + path_str2arr VYATTA_EDIT_LEVEL path_arr + local path_str="${path_arr[*]}" + set_config_ps1 "$path_str" +} + really_exit() { sudo umount $VYATTA_TEMP_CONFIG_DIR -- cgit v1.2.3