[pacman-dev] [PATCH 1/4] pacdiff: color filename and mention what we found
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- contrib/pacdiff.sh.in | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/contrib/pacdiff.sh.in b/contrib/pacdiff.sh.in index bfafda2..5797fef 100644 --- a/contrib/pacdiff.sh.in +++ b/contrib/pacdiff.sh.in @@ -62,7 +62,15 @@ fi # 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}" + + case "$file_type" in + pacnew) printf "\e[0;32m%s\e[0m" "$file_type";; + pacorig) printf "\e[0;33m%s\e[0m" "$file_type";; + pacsave) printf "\e[0;34m%s\e[0m" "$file_type";; + esac + + printf " found for \e[0;35m%s\e[0m\n" "$file" if [ ! -f "$file" ]; then echo " $file does not exist" rm -i "$pacfile" -- 1.8.0.2
Doesn't hurt and reassures the user that we did the right thing. Signed-off-by: Florian Pritz <bluewind@xinu.at> --- contrib/pacdiff.sh.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/pacdiff.sh.in b/contrib/pacdiff.sh.in index 5797fef..2e67424 100644 --- a/contrib/pacdiff.sh.in +++ b/contrib/pacdiff.sh.in @@ -73,21 +73,21 @@ while IFS= read -u 3 -r -d '' pacfile; do printf " found for \e[0;35m%s\e[0m\n" "$file" if [ ! -f "$file" ]; then echo " $file does not exist" - rm -i "$pacfile" + rm -iv "$pacfile" continue fi check="$(cmp "$pacfile" "$file")" if [ -z "${check}" ]; then echo " Files are identical, removing..." - rm "$pacfile" + rm -v "$pacfile" else echo -n " File differences found. (V)iew, (S)kip, (R)emove: [v/s/r] " while read c; do case $c in - r|R) rm "$pacfile"; break ;; + r|R) rm -v "$pacfile"; 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 ;; esac -- 1.8.0.2
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- contrib/pacdiff.sh.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/pacdiff.sh.in b/contrib/pacdiff.sh.in index 2e67424..97584b5 100644 --- a/contrib/pacdiff.sh.in +++ b/contrib/pacdiff.sh.in @@ -76,8 +76,8 @@ while IFS= read -u 3 -r -d '' pacfile; do rm -iv "$pacfile" continue fi - check="$(cmp "$pacfile" "$file")" - if [ -z "${check}" ]; then + + if cmp -s "$pacfile" "$file"; then echo " Files are identical, removing..." rm -v "$pacfile" else -- 1.8.0.2
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- contrib/pacdiff.sh.in | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/contrib/pacdiff.sh.in b/contrib/pacdiff.sh.in index 97584b5..477a7ac 100644 --- a/contrib/pacdiff.sh.in +++ b/contrib/pacdiff.sh.in @@ -81,15 +81,16 @@ while IFS= read -u 3 -r -d '' pacfile; do echo " Files are identical, removing..." rm -v "$pacfile" else - echo -n " File differences found. (V)iew, (S)kip, (R)emove: [v/s/r] " + echo -n " (V)iew, (S)kip, (R)emove $file_type, (O)verwrite with $file_type: [v/s/r/o] " while read c; do case $c in r|R) rm -v "$pacfile"; break ;; + o|O) mv -v "$pacfile" "$file"; break ;; v|V) $diffprog "$pacfile" "$file" rm -iv "$pacfile"; break ;; s|S) break ;; - *) echo -n " Invalid answer. Try again: [v/s/r] "; continue ;; + *) echo -n " Invalid answer. Try again: [v/s/r/o] "; continue ;; esac done fi -- 1.8.0.2
On 20/12/12 08:33, Florian Pritz wrote:
Signed-off-by: Florian Pritz <bluewind@xinu.at> ---
Look at makepkg for how colors should be enabled.
contrib/pacdiff.sh.in | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/contrib/pacdiff.sh.in b/contrib/pacdiff.sh.in index bfafda2..5797fef 100644 --- a/contrib/pacdiff.sh.in +++ b/contrib/pacdiff.sh.in @@ -62,7 +62,15 @@ fi # 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}" + + case "$file_type" in + pacnew) printf "\e[0;32m%s\e[0m" "$file_type";; + pacorig) printf "\e[0;33m%s\e[0m" "$file_type";; + pacsave) printf "\e[0;34m%s\e[0m" "$file_type";; + esac + + printf " found for \e[0;35m%s\e[0m\n" "$file" if [ ! -f "$file" ]; then echo " $file does not exist" rm -i "$pacfile"
participants (2)
-
Allan McRae
-
Florian Pritz