aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-09-28 17:47:08 (GMT)
committerZac Medico <zmedico@gentoo.org>2011-09-28 17:47:08 (GMT)
commit374aa37ece5d67d003da358e35f0326da3cd2397 (patch)
treef9dd056dbbe1f8bdaba2faadbd277b090ae792c3
parentarchive-conf: dispatch_conf import bug #384665 (diff)
downloadportage-374aa37ece5d67d003da358e35f0326da3cd2397.zip
portage-374aa37ece5d67d003da358e35f0326da3cd2397.tar.gz
portage-374aa37ece5d67d003da358e35f0326da3cd2397.tar.bz2
etc-update: support PAGER env var for bug #384663
-rwxr-xr-xbin/etc-update11
-rw-r--r--cnf/etc-update.conf12
2 files changed, 16 insertions, 7 deletions
diff --git a/bin/etc-update b/bin/etc-update
index 42518ad..2af04cc 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 cea2173..9709862 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: