diff options
author | Tom Grennan <tgrennan@io.vyatta.com> | 2007-11-30 12:23:56 -0800 |
---|---|---|
committer | Tom Grennan <tgrennan@io.vyatta.com> | 2007-11-30 12:23:56 -0800 |
commit | 20bfe68eddfa1181cdf91aeb45f65fe717a1fb93 (patch) | |
tree | bb41c61a2be8a315ec90415ea6b3f56e84644a9f /etc | |
parent | fc05a43ce19c57f8bb4abd68a8e973b9e048ea19 (diff) | |
download | vyatta-op-20bfe68eddfa1181cdf91aeb45f65fe717a1fb93.tar.gz vyatta-op-20bfe68eddfa1181cdf91aeb45f65fe717a1fb93.zip |
fix bug 2486
pipe "show" commands and help through pager
Diffstat (limited to 'etc')
-rw-r--r-- | etc/bash_completion.d/10vyatta-op | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/etc/bash_completion.d/10vyatta-op b/etc/bash_completion.d/10vyatta-op index 0651618..dacf57f 100644 --- a/etc/bash_completion.d/10vyatta-op +++ b/etc/bash_completion.d/10vyatta-op @@ -22,6 +22,17 @@ # # **** End License **** +declare -r _vyatta_default_pager="less\ + --QUIT-AT-EOF\ + --quit-if-one-screen\ + --LONG-PROMPT\ + --RAW-CONTROL-CHARS\ + --squeeze-blank-lines\ + --buffers=64\ + --auto-buffers\ + --no-lessopen" +declare -x VYATTA_PAGER=$_vyatta_default_pager + test -f /etc/default/vyatta && \ source /etc/default/vyatta @@ -147,7 +158,7 @@ _vyatta_op_help () _vyatta_op_compreply () { local cur=$1; shift - local -a comps justhelp + local -a justhelp comps scomps # donot complete entries like <HOSTNAME> or <A.B.C.D> for allow ; do @@ -158,7 +169,9 @@ _vyatta_op_compreply () fi done - COMPREPLY=($( compgen -W "${comps[*]}" -- $cur )) + scomps=($( printf "%s\n" ${comps[@]} | sort -u )) + + COMPREPLY=($( compgen -W "${scomps[*]}" -- $cur )) # if the last command line arg is empty and we have # an empty completion option (meaning wild card), @@ -176,9 +189,8 @@ _vyatta_op_compreply () fi if [ "${COMP_WORDS[*]}" == "$_vyatta_op_last_comp" ] ; then - _vyatta_op_help "$cur" "$node_path" \ - ${justhelp[@]} \ - $(printf "%s\n" ${comps[@]} | sort) + _vyatta_op_help "$cur" "$node_path" ${justhelp[@]} ${scomps[@]} | \ + eval ${VYATTA_PAGER:-cat} COMPREPLY=( "" " " ) _vyatta_op_last_comp="" else @@ -254,7 +266,11 @@ _vyatta_op_run () local run_cmd=$(_vyatta_op_get_node_def_field $tpath/node.def run) local ret=0 if [ -n "$run_cmd" ]; then - eval "$run_cmd" + if [ "$1" == "show" ] ; then + ( eval "$run_cmd" ) | eval "${VYATTA_PAGER:-cat}" + else + eval "$run_cmd" + fi else echo "Incomplete command" >&2 ret=1 |