From 374aa37ece5d67d003da358e35f0326da3cd2397 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Wed, 28 Sep 2011 10:47:08 -0700 Subject: etc-update: support PAGER env var for bug #384663 --- bin/etc-update | 11 ++++++++++- cnf/etc-update.conf | 12 ++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/bin/etc-update b/bin/etc-update index 42518adc6..2af04cc4c 100755 --- a/bin/etc-update +++ b/bin/etc-update @@ -33,6 +33,12 @@ get_config() { "${PORTAGE_CONFIGROOT}"etc/etc-update.conf) } +cmd_var_is_valid() { + # return true if the first whitespace-separated token contained + # in "${1}" is an executable file, false otherwise + [[ -x $(type -P ${1%%[[:space:]]*}) ]] +} + diff_command() { local cmd=${diff_command//%file1/$1} ${cmd//%file2/$2} @@ -566,7 +572,10 @@ using_editor=$(get_config using_editor) merge_command=$(get_config merge_command) declare -i mode=$(get_config mode) [[ -z ${mode} ]] && mode=0 -[[ -z ${pager} ]] && pager="cat" +if ! cmd_var_is_valid "${pager}" ; then + pager=${PAGER} + cmd_var_is_valid "${pager}" || pager=cat +fi if [ "${using_editor}" == 0 ]; then # Sanity check to make sure diff exists and works diff --git a/cnf/etc-update.conf b/cnf/etc-update.conf index cea21739e..970986251 100644 --- a/cnf/etc-update.conf +++ b/cnf/etc-update.conf @@ -21,9 +21,9 @@ mv_opts="-i" # arguments used whenever cp is called cp_opts="-i" -# pager for use with diff commands -pager="less" -#pager="" +# set the pager for use with diff commands (this will +# cause the PAGER environment variable to be ignored) +#pager="less" # For emacs-users (see NOTE_2) # diff_command="eval emacs -nw --eval=\'\(ediff\ \"%file1\"\ \"%file2\"\)\'" @@ -47,9 +47,9 @@ merge_command="sdiff -s -o %merged %orig %new" # pager: # # Examples of pager usage: -# pager="" # don't use a pager -# pager="less -E" # less -# pager="more" # more +# pager="cat" # don't use a pager +# pager="less -E" # less +# pager="more" # more # # # diff_command: -- cgit v1.2.3-1-g7c22