MANDATORY_OPTS = [ 'archive-dir', 'diff', 'replace-cvs', 'replace-wscomments', 'merge' ]
+def cmd_var_is_valid(cmd):
+ """
+ Return true if the first whitespace-separated token contained
+ in cmd is an executable file, false otherwise.
+ """
+ cmd = portage.util.shlex_split(cmd)
+ if not cmd:
+ return False
+
+ if os.path.isabs(cmd[0]):
+ return os.access(cmd[0], os.EX_OK)
+
+ return find_binary(cmd[0]) is not None
+
class dispatch:
options = {}
else:
self.options["log-file"] = "/dev/null"
+ pager = self.options.get("pager")
+ if pager is None or not cmd_var_is_valid(pager):
+ pager = os.environ.get("PAGER")
+ if pager is None or not cmd_var_is_valid(pager):
+ pager = "cat"
+
+ if os.path.basename(pager) == "less":
+ less_opts = self.options.get("less-opts")
+ if less_opts is not None and less_opts.strip():
+ pager += " " + less_opts
+
+ if os.path.basename(portage.util.shlex_split(pager)[0]) == "cat":
+ pager = ""
+ else:
+ pager = " | " + pager
+
#
# Build list of extant configs
#
clear_screen()
if show_new_diff:
cmd = self.options['diff'] % (conf['new'], mrgconf)
+ cmd += pager
spawn_shell(cmd)
show_new_diff = 0
else:
cmd = self.options['diff'] % (conf['current'], newconf)
+ cmd += pager
spawn_shell(cmd)
print()
# %s new file
# If using colordiff instead of diff, the less -R option may be required
# for correct display.
-diff="diff -Nu '%s' '%s' | less --no-init --QUIT-AT-EOF"
+diff="diff -Nu '%s' '%s'"
+
+# Set the pager for use with diff commands (this will
+# cause the PAGER environment variable to be ignored).
+# Setting pager="cat" will disable pager usage.
+pager=""
+
+# Default options used if less is the pager
+less-opts="--no-init --QUIT-AT-EOF"
# Diff for interactive merges.
# %s output file