From 20bfe68eddfa1181cdf91aeb45f65fe717a1fb93 Mon Sep 17 00:00:00 2001 From: Tom Grennan Date: Fri, 30 Nov 2007 12:23:56 -0800 Subject: fix bug 2486 pipe "show" commands and help through pager --- etc/bash_completion.d/10vyatta-op | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'etc/bash_completion.d') 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 or 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 -- cgit v1.2.3