pacdiff: automatically delete pacfile after viewing if identical

Message ID 66d7ee9e-459b-679e-8df9-c7019b9514f2@zlima12.com
State Accepted, archived
Headers show
Series
  • pacdiff: automatically delete pacfile after viewing if identical
Related show

Commit Message

John A. Leuenhagen Oct. 5, 2020, 6:24 p.m. UTC
Signed-off-by: John A. Leuenhagen <john@zlima12.com>
---
 src/pacdiff.sh.in | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Johannes Löthberg Oct. 23, 2020, 2:58 p.m. UTC | #1
Excerpts from John A. Leuenhagen's message of October 5, 2020 20:24:
> Signed-off-by: John A. Leuenhagen <john@zlima12.com>
> ---
>  src/pacdiff.sh.in | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/src/pacdiff.sh.in b/src/pacdiff.sh.in
> index e3b8f8c..af85abb 100644
> --- a/src/pacdiff.sh.in
> +++ b/src/pacdiff.sh.in
> @@ -184,6 +184,11 @@ while IFS= read -u 3 -r -d '' pacfile; do
>  				o|O) mv -v "$pacfile" "$file"; break ;;
>  				v|V)
>  					$diffprog "$pacfile" "$file"
> +					if cmp -s "$pacfile" "$file"; then
> +						msg2 "Files are identical, removing..."
> +						rm -v "$pacfile"
> +						break
> +					fi
>  					ask "(V)iew, (S)kip, (R)emove %s, (O)verwrite with %s, (Q)uit: [v/s/r/o/q] " "$file_type" "$file_type";
>  					continue ;;
>  				s|S) break ;;
> -- 
> 2.28.0
> 

Applied, thanks.

Patch

diff --git a/src/pacdiff.sh.in b/src/pacdiff.sh.in
index e3b8f8c..af85abb 100644
--- a/src/pacdiff.sh.in
+++ b/src/pacdiff.sh.in
@@ -184,6 +184,11 @@  while IFS= read -u 3 -r -d '' pacfile; do
 				o|O) mv -v "$pacfile" "$file"; break ;;
 				v|V)
 					$diffprog "$pacfile" "$file"
+					if cmp -s "$pacfile" "$file"; then
+						msg2 "Files are identical, removing..."
+						rm -v "$pacfile"
+						break
+					fi
 					ask "(V)iew, (S)kip, (R)emove %s, (O)verwrite with %s, (Q)uit: [v/s/r/o/q] " "$file_type" "$file_type";
 					continue ;;
 				s|S) break ;;