From 9eb390403b8f5ad6ea527cbd3e5f0da192543062 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Thu, 17 Nov 2016 10:58:10 -0800 Subject: [PATCH] Implement -p option to disable PAGER Signed-off-by: Tom Eastep --- Shorewall-core/lib.cli | 42 +++++++++++++++++++++++++++--------------- Shorewall/lib.cli-std | 28 +++++++++++++++------------- 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/Shorewall-core/lib.cli b/Shorewall-core/lib.cli index 0e0fa595f..83d895753 100644 --- a/Shorewall-core/lib.cli +++ b/Shorewall-core/lib.cli @@ -1161,7 +1161,11 @@ show_macros() { done } +show_a_macro() { echo "Shorewall $SHOREWALL_VERSION Macro $1 at $g_hostname - $(date)" + cat ${directory}/macro.$1 +} + # # Show Command Executor # @@ -3992,24 +3996,26 @@ get_config() { g_loopback=$(find_loopback_interfaces) - [ -n "$PAGER" ] || PAGER=$DEFAULT_PAGER + if [ -z "$g_nopager" ]; then + [ -n "$PAGER" ] || PAGER=$DEFAULT_PAGER - if [ -n "$PAGER" -a -t 1 ]; then - case $PAGER in - /*) - g_pager="$PAGER" - [ -f "$g_pager" ] || fatal_error "PAGER=$PAGER does not exist" - ;; - *) - g_pager=$(mywhich $PAGER 2> /dev/null) - [ -n "$g_pager" ] || fatal_error "PAGER=$PAGER does not exist" - ;; - esac + if [ -n "$PAGER" -a -t 1 ]; then + case $PAGER in + /*) + g_pager="$PAGER" + [ -f "$g_pager" ] || fatal_error "PAGER=$PAGER does not exist" + ;; + *) + g_pager=$(mywhich $PAGER 2> /dev/null) + [ -n "$g_pager" ] || fatal_error "PAGER=$PAGER does not exist" + ;; + esac - [ -x "$g_pager" ] || fatal_error "PAGER $g_pager is not executable" + [ -x "$g_pager" ] || fatal_error "PAGER $g_pager is not executable" - g_pager="| $g_pager" - fi + g_pager="| $g_pager" + fi + fi if [ -n "$DYNAMIC_BLACKLIST" ]; then setup_dbl @@ -4357,6 +4363,7 @@ shorewall_cli() { g_loopback= g_compiled= g_pager= + g_nopager= g_blacklistipset= g_disconnect= @@ -4453,6 +4460,11 @@ shorewall_cli() { g_timestamp=Yes option=${option#t} ;; + p*) + g_nopager=Yes + option=${option#p} + ;; + -) finished=1 option= diff --git a/Shorewall/lib.cli-std b/Shorewall/lib.cli-std index 39eab5f0d..a5eb14815 100644 --- a/Shorewall/lib.cli-std +++ b/Shorewall/lib.cli-std @@ -318,21 +318,23 @@ get_config() { [ -n "$PAGER" ] || PAGER=$DEFAULT_PAGER - if [ -n "$PAGER" -a -t 1 ]; then - case $PAGER in - /*) - g_pager="$PAGER" - [ -f "$g_pager" ] || fatal_error "PAGER $PAGER does not exist" - ;; - *) - g_pager=$(mywhich $PAGER 2> /dev/null) - [ -n "$g_pager" ] || fatal_error "PAGER $PAGER not found" - ;; - esac + if [ -z "$g_nopager" ]; then + if [ -n "$PAGER" -a -t 1 ]; then + case $PAGER in + /*) + g_pager="$PAGER" + [ -f "$g_pager" ] || fatal_error "PAGER $PAGER does not exist" + ;; + *) + g_pager=$(mywhich $PAGER 2> /dev/null) + [ -n "$g_pager" ] || fatal_error "PAGER $PAGER not found" + ;; + esac - [ -x "$g_pager" ] || fatal_error "PAGER $g_pager is not executable" + [ -x "$g_pager" ] || fatal_error "PAGER $g_pager is not executable" - g_pager="| $g_pager" + g_pager="| $g_pager" + fi fi if [ -n "$DYNAMIC_BLACKLIST" ]; then