diff options
author | Manoj Srivastava <srivasta@debian.org> | 2007-05-05 16:38:57 +0000 |
---|---|---|
committer | Manoj Srivastava <srivasta@debian.org> | 2007-05-05 16:38:57 +0000 |
commit | ac5304ed8790d52f594329796afc0d112af503a9 (patch) | |
tree | 52f5ce2468182b98e9c02e4efcbb27ee9dd2590c /ucf | |
parent | e07f22d0072e7d6ab04846d3d80aa3b36436db1c (diff) |
Add support for displaying diffs using debconf itself
Users using a Graphical frontend are surprised when the display apparently
just blocks when they ask to see a diff (or 3-way diff) of the
configuration file being handled, when actually the diff is displayed on
the terminal window ucf was run on. Until the debconf-escape utility and
the escape CAPB support, db_subst ran into newline and line length
issues. Patch from Michael Vogt.
Closes: Bug#325576
* ucf (show_diff): Added a function to show the diff using debconf
* ucf (newsum): Use it
git-archimport-id: srivasta@debian.org--lenny/ucf--devel--2.0--patch-2
Diffstat (limited to 'ucf')
-rwxr-xr-x | ucf | 68 |
1 files changed, 35 insertions, 33 deletions
@@ -57,6 +57,27 @@ setq() { fi } +# Use debconf to show the differences +show_diff() { + if [ -z "$1" ]; then + echo >&2 "need a diff as argument" + exit 1; + fi + DIFF="$1" + if [ "$DEBCONF_OK" = "YES" ] && [ "$DEBIAN_HAS_FRONTEND" ]; then + templ=ucf/show_diff + db_capb escape + db_reset $templ + db_subst $templ DIFF "$(printf %s "$DIFF" | debconf-escape -e)" + db_input critical $templ || true + db_go + db_get $templ + db_capb + else + echo "$DIFF" | sensible-pager + fi +} + withecho () { echo " $@" >&2 "$@" @@ -870,59 +891,40 @@ EOPEND ;; "$choice_diff"|D|d) if [ -e "$dest_file" ]; then - ( diff -uBbw "$dest_file" "$new_file" | \ - sensible-pager ) </dev/tty >/dev/tty + DIFF="$(diff -uBbw "$dest_file" "$new_file")" || true else - ( diff -uBbw /dev/null "$new_file" | \ - sensible-pager ) </dev/tty >/dev/tty - fi - if [ "X$STOP" != "X" ]; then - echo >&2 "Please hit enter to continue"; - read -e ANSWER </dev/tty + DIFF="$(diff -uBbw /dev/null "$new_file")" || true fi + show_diff "$DIFF" ;; "$choice_sdiff"|S|s) if [ -e "$dest_file" ]; then - ( sdiff -BbW "$dest_file" "$new_file" | \ - sensible-pager ) </dev/tty >/dev/tty + DIFF="$( sdiff -BbW "$dest_file" "$new_file")" || true else - ( sdiff -BbW /dev/null "$new_file" | \ - sensible-pager ) </dev/tty >/dev/tty - fi - if [ "X$STOP" != "X" ]; then - echo >&2 "Please hit enter to continue"; - read -e ANSWER </dev/tty + DIFF="$(sdiff -BbW /dev/null "$new_file")" || true fi + show_diff "$DIFF" ;; "$choice_diff_threeway"|3|t|T) if [ -e "$statedir/cache/$cached_file" \ -a "X$THREEWAY" != "X" ]; then if [ -e "$dest_file" ]; then - ( diff3 -L Current -L Older -L New -A \ + DIFF="$(diff3 -L Current -L Older -L New -A \ "$dest_file" "$statedir/cache/$cached_file" \ - "$new_file" | sensible-pager ) >/dev/tty </dev/tty + "$new_file")" || true else - ( diff3 -L Current -L Older -L New -A \ + DIFF="$(diff3 -L Current -L Older -L New -A \ /dev/null "$statedir/cache/$cached_file" \ - "$new_file" | sensible-pager ) >/dev/tty </dev/tty + "$new_file")" || true fi - if [ "X$STOP" != "X" ]; then - echo >&2 "Please hit enter to continue"; - read -e ANSWER </dev/tty - fi + show_diff "$DIFF" else if [ -e "$dest_file" ]; then - ( diff -uBbw "$dest_file" "$new_file" | \ - sensible-pager ) </dev/tty >/dev/tty + DIFF="$(diff -uBbw "$dest_file" "$new_file")" || true else - ( diff -uBbw /dev/null "$new_file" | \ - sensible-pager ) </dev/tty >/dev/tty - fi - - if [ "X$STOP" != "X" ]; then - echo >&2 "Please hit enter to continue"; - read -e ANSWER </dev/tty + DIFF="$(diff -uBbw /dev/null "$new_file")" || true fi + show_diff "$DIFF" fi ;; "$choice_merge_threeway"|M|m) |