[pacman-dev] [PATCH v2 8/9] pacdiff: provide an --output option to show any .pac* files

Jonathan Frazier eyeswide at gmail.com
Mon Jul 22 21:22:59 EDT 2013


This is an option to just echo's the pacnews/pacsaves instead of merging
or removing them. This can be used to check the config status such as in
a cron job without modifying the system.

Signed-off-by: Jonathan Frazier <eyeswide at gmail.com>
---
 contrib/pacdiff.sh.in | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/contrib/pacdiff.sh.in b/contrib/pacdiff.sh.in
index e76ad4b..6b5edb9 100644
--- a/contrib/pacdiff.sh.in
+++ b/contrib/pacdiff.sh.in
@@ -27,7 +27,7 @@ diffprog=${DIFFPROG:-vimdiff}
 diffsearchpath=${DIFFSEARCHPATH:-/etc}
 USE_COLOR='y'
 declare -a oldsaves
-declare -i FIND=0 LOCATE=0 PACDB=0
+declare -i FIND=0 LOCATE=0 PACDB=0 OUTPUTONLY=0
 
 m4_include(../scripts/library/output_format.sh)
 
@@ -43,6 +43,7 @@ Search Options:     select one, default: find
   -p/--pacmandb     scan active config files from pacman db
 
 General Options:
+  -o/--output       print files instead of merging them
   --nocolor         remove colors from output
 
 Enviroment Variables:
@@ -51,6 +52,7 @@ Enviroment Variables:
                     (default: /etc)
 
 Example: DIFFPROG=meld DIFFSEARCHPATH="/boot /etc /usr" $myname
+Example: $myname --output --locate
 
 EOF
 }
@@ -98,6 +100,8 @@ while [[ -n "$1" ]]; do
 			FIND=1;;
 		-p|--pacmandb)
 			PACDB=1;;
+		-o|--output)
+			OUTPUTONLY=1;;
 		--nocolor)
 			USE_COLOR='n';;
 		-V|--version)
@@ -136,6 +140,11 @@ fi
 while IFS= read -u 3 -r -d '' pacfile; do
 	file="${pacfile%.pac*}"
 	file_type="pac${pacfile##*.pac}"
+	
+	if (( OUTPUTONLY )); then
+		echo "$pacfile"
+		continue
+	fi
 
 	# add matches for pacsave.N to oldsaves array, do not prompt
 	if [[ $file_type = pacsave.+([0-9]) ]]; then
-- 
1.8.3.2



More information about the pacman-dev mailing list