1 |
commit: 374aa37ece5d67d003da358e35f0326da3cd2397 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Sep 28 17:47:08 2011 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Sep 28 17:47:08 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=374aa37e |
7 |
|
8 |
etc-update: support PAGER env var for bug #384663 |
9 |
|
10 |
--- |
11 |
bin/etc-update | 11 ++++++++++- |
12 |
cnf/etc-update.conf | 12 ++++++------ |
13 |
2 files changed, 16 insertions(+), 7 deletions(-) |
14 |
|
15 |
diff --git a/bin/etc-update b/bin/etc-update |
16 |
index 42518ad..2af04cc 100755 |
17 |
--- a/bin/etc-update |
18 |
+++ b/bin/etc-update |
19 |
@@ -33,6 +33,12 @@ get_config() { |
20 |
"${PORTAGE_CONFIGROOT}"etc/etc-update.conf) |
21 |
} |
22 |
|
23 |
+cmd_var_is_valid() { |
24 |
+ # return true if the first whitespace-separated token contained |
25 |
+ # in "${1}" is an executable file, false otherwise |
26 |
+ [[ -x $(type -P ${1%%[[:space:]]*}) ]] |
27 |
+} |
28 |
+ |
29 |
diff_command() { |
30 |
local cmd=${diff_command//%file1/$1} |
31 |
${cmd//%file2/$2} |
32 |
@@ -566,7 +572,10 @@ using_editor=$(get_config using_editor) |
33 |
merge_command=$(get_config merge_command) |
34 |
declare -i mode=$(get_config mode) |
35 |
[[ -z ${mode} ]] && mode=0 |
36 |
-[[ -z ${pager} ]] && pager="cat" |
37 |
+if ! cmd_var_is_valid "${pager}" ; then |
38 |
+ pager=${PAGER} |
39 |
+ cmd_var_is_valid "${pager}" || pager=cat |
40 |
+fi |
41 |
|
42 |
if [ "${using_editor}" == 0 ]; then |
43 |
# Sanity check to make sure diff exists and works |
44 |
|
45 |
diff --git a/cnf/etc-update.conf b/cnf/etc-update.conf |
46 |
index cea2173..9709862 100644 |
47 |
--- a/cnf/etc-update.conf |
48 |
+++ b/cnf/etc-update.conf |
49 |
@@ -21,9 +21,9 @@ mv_opts="-i" |
50 |
# arguments used whenever cp is called |
51 |
cp_opts="-i" |
52 |
|
53 |
-# pager for use with diff commands |
54 |
-pager="less" |
55 |
-#pager="" |
56 |
+# set the pager for use with diff commands (this will |
57 |
+# cause the PAGER environment variable to be ignored) |
58 |
+#pager="less" |
59 |
|
60 |
# For emacs-users (see NOTE_2) |
61 |
# diff_command="eval emacs -nw --eval=\'\(ediff\ \"%file1\"\ \"%file2\"\)\'" |
62 |
@@ -47,9 +47,9 @@ merge_command="sdiff -s -o %merged %orig %new" |
63 |
# pager: |
64 |
# |
65 |
# Examples of pager usage: |
66 |
-# pager="" # don't use a pager |
67 |
-# pager="less -E" # less |
68 |
-# pager="more" # more |
69 |
+# pager="cat" # don't use a pager |
70 |
+# pager="less -E" # less |
71 |
+# pager="more" # more |
72 |
# |
73 |
# |
74 |
# diff_command: |