commit:     246373bbe52c55e912381d8555cceb70db0ec41b
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 22 19:10:07 2017 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Feb 22 21:57:28 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=246373bb

etc-update: fix hang when using_editor is set, bug #544440

Don't try to use an interactive editor to obtain the difference between
files.  Fall back to plain `diff -q` in this case.

X-Gentoo-Bug: 544440
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=544440

 bin/etc-update | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/bin/etc-update b/bin/etc-update
index e0f7224dc..ea69f1478 100755
--- a/bin/etc-update
+++ b/bin/etc-update
@@ -649,10 +649,21 @@ do_distconf() {
                elif [[ -L ${efile} || -L ${file} ]] ; then
                        # not the same file types
                        continue
-               elif diff_command "${file}" "${efile}" &> /dev/null; then
-                       # replace identical copy
-                       mv "${file}" "${efile}"
-                       break
+               else
+                       local ret=
+                       if [[ ${using_editor} == 0 ]] ; then
+                               diff_command "${file}" "${efile}" &> /dev/null
+                               ret=$?
+                       else
+                               # fall back to plain diff
+                               diff -q "${file}" "${efile}" &> /dev/null
+                               ret=$?
+                       fi
+                       if [[ ${ret} == 0 ]] ; then
+                               # replace identical copy
+                               mv "${file}" "${efile}"
+                               break
+                       fi
                fi
        done
 }

Reply via email to