summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAn-Cheng Huang <ancheng@vyatta.com>2008-02-01 16:50:54 -0800
committerAn-Cheng Huang <ancheng@vyatta.com>2008-02-01 16:50:54 -0800
commitb74a46d1c13446aeca6709ccea3ce093069f4eb9 (patch)
treeb3c7c3b8a286f4b9351310e99c06a8a25b0d073e
parent8b12ff7af456406432a0eed0549c24507bdd5d01 (diff)
downloadvyatta-cfg-b74a46d1c13446aeca6709ccea3ce093069f4eb9.tar.gz
vyatta-cfg-b74a46d1c13446aeca6709ccea3ce093069f4eb9.zip
fix for bug 2616: implement "up" and "top" in configure mode.
-rw-r--r--etc/bash_completion.d/20vyatta-cfg35
1 files changed, 34 insertions, 1 deletions
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