# pacdiff : a simple pacnew/pacorig/pacsave updater
#
# Copyright (c) 2007 Aaron Griffin <aaronmgriffin@gmail.com>
+# Copyright (c) 2013 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diffprog=${DIFFPROG:-vimdiff}
diffsearchpath=${DIFFSEARCHPATH:-/etc}
locate=0
+USE_COLOR='y'
+
+m4_include(../scripts/library/output_format.sh)
+
+m4_include(../scripts/library/term_colors.sh)
usage() {
echo "$myname : a simple pacnew/pacorig/pacsave updater"
version() {
printf "%s %s\n" "$myname" "$myver"
echo 'Copyright (C) 2007 Aaron Griffin <aaronmgriffin@gmail.com>'
+ echo 'Copyright (C) 2013 Pacman Development Team <pacman-dev@archlinux.org>'
}
cmd() {
# see http://mywiki.wooledge.org/BashFAQ/020
while IFS= read -u 3 -r -d '' pacfile; do
file="${pacfile%.pac*}"
- echo "File: $file"
+ file_type="pac${pacfile##*.pac}"
+
+ msg "%s file found for %s" "$file_type" "$file"
if [ ! -f "$file" ]; then
- echo " $file does not exist"
- rm -i "$pacfile"
+ warning "$file does not exist"
+ rm -iv "$pacfile"
continue
fi
- check="$(cmp "$pacfile" "$file")"
- if [ -z "${check}" ]; then
- echo " Files are identical, removing..."
- rm "$pacfile"
+
+ if cmp -s "$pacfile" "$file"; then
+ msg2 "Files are identical, removing..."
+ rm -v "$pacfile"
else
- echo -n " File differences found. (V)iew, (S)kip, (R)emove: [v/s/r] "
+ ask "(V)iew, (S)kip, (R)emove %s, (O)verwrite with %s, (Q)uit: [v/s/r/o/q] " "$file_type" "$file_type"
while read c; do
case $c in
- r|R) rm "$pacfile"; break ;;
+ q|Q) exit 0;;
+ r|R) rm -v "$pacfile"; break ;;
+ o|O) mv -v "$pacfile" "$file"; break ;;
v|V)
$diffprog "$pacfile" "$file"
- rm -i "$pacfile"; break ;;
+ rm -iv "$pacfile"; break ;;
s|S) break ;;
- *) echo -n " Invalid answer. Try again: [v/s/r] "; continue ;;
+ *) ask "Invalid answer. Try again: [v/s/r/o/q] "; continue ;;
esac
done
fi