summaryrefslogtreecommitdiffstats
path: root/bin/etc-update
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2007-10-07 19:06:49 +0000
committerMike Frysinger <vapier@gentoo.org>2007-10-07 19:06:49 +0000
commit4cc204767c22c9b341bdade574f751289611ad13 (patch)
tree255eb1a356654547d43f2ff1845ed86a4f97103a /bin/etc-update
parente21350865602e559365b2f8b95918f744fa0f813 (diff)
downloadportage-4cc204767c22c9b341bdade574f751289611ad13.tar.gz
portage-4cc204767c22c9b341bdade574f751289611ad13.tar.bz2
portage-4cc204767c22c9b341bdade574f751289611ad13.zip
unify diff_command handling
svn path=/main/trunk/; revision=7992
Diffstat (limited to 'bin/etc-update')
-rwxr-xr-xbin/etc-update35
1 files changed, 19 insertions, 16 deletions
diff --git a/bin/etc-update b/bin/etc-update
index ac1cd8e3e..d40400d19 100755
--- a/bin/etc-update
+++ b/bin/etc-update
@@ -34,6 +34,11 @@ get_config() {
"${PORTAGE_CONFIGROOT}"etc/etc-update.conf)
}
+diff_command() {
+ local cmd=${diff_command//%file1/$1}
+ ${cmd//%file2/$2}
+}
+
scan() {
echo "Scanning Configuration files..."
@@ -44,12 +49,6 @@ scan() {
local find_opts
local my_basename
- # Sanity check to make sure diff exists and works
- if ! diff -v &>/dev/null ; then
- echo "ERROR: 'diff' does not seem to work, aborting"
- exit 1
- fi
-
for path in ${CONFIG_PROTECT} ; do
path="${ROOT}${path}"
find_opts="-iname ._cfg????_*"
@@ -312,17 +311,14 @@ do_cfg() {
elif [[ "${DELETE_ALL}" == "yes" ]] && ! user_special "${ofile}"; then
my_input=2
else
- showdiffcmd=$(echo "${diff_command}" |
- sed -e "s:%file1:${ofile}:" -e "s:%file2:${file}:")
-
if [ "${using_editor}" == 0 ]; then
(
echo "Showing differences between ${ofile} and ${file}"
- ${showdiffcmd}
+ diff_command "${ofile}" "${file}"
) | ${pager}
else
echo "Beginning of differences between ${ofile} and ${file}"
- ${showdiffcmd}
+ diff_command "${ofile}" "${file}"
echo "End of differences between ${ofile} and ${file}"
fi
if [ -L "${file}" ]; then
@@ -415,9 +411,7 @@ Please select from the menu above (-1 to exit, losing this merge): "
return 255
;;
2) ( echo "Showing differences between ${ofile} and ${mfile}"
- $(echo "${diff_command}" | \
- sed -e "s:%file1:${ofile}:" \
- -e "s:%file2:${mfile}:") ) | ${pager}
+ diff_command "${ofile}" "${mfile}" ) | ${pager}
continue
;;
3) break
@@ -490,8 +484,17 @@ diff_command=$(get_config diff_command)
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"
+[[ -z ${mode} ]] && mode=0
+[[ -z ${pager} ]] && pager="cat"
+
+# Sanity check to make sure diff exists and works
+echo > "${TMP}"/.diff-test-1
+echo > "${TMP}"/.diff-test-2
+
+if ! diff_command "${TMP}"/.diff-test-1 "${TMP}"/.diff-test-2 &> /dev/null ; then
+ echo "ERROR: '${diff_command}' does not seem to work, aborting"
+ exit 1
+fi
#echo "rm_opts: $rm_opts, mv_opts: $mv_opts, cp_opts: $cp_opts"
#echo "pager: $pager, diff_command: $diff_command, merge_command: $merge_command"