Verified Commit 348a2969 authored by Denton Liu via pacman-contrib's avatar Denton Liu via pacman-contrib Committed by Daniel M. Capella
Browse files

pacdiff: Reduce repetition in input loop



The input loop repeats the `ask` code twice. In a future commit, we will
be introducing another instance of the `ask` code. This makes it
possible to mistakenly make the code to get out of sync.

Refactor the loop so that the `ask` code happens once at the top of the
loop. This introduces one functional change in the "Invalid answer" case
but it also makes it more consistent with the remaining cases.

Signed-off-by: default avatarDenton Liu <liu.denton@gmail.com>
Signed-off-by: Daniel M. Capella's avatarDaniel M. Capella <polyzen@archlinux.org>
parent b675c927
......@@ -180,8 +180,9 @@ while IFS= read -u 3 -r -d '' pacfile; do
msg2 "Files are identical, removing..."
rm -v "$pacfile"
else
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
while :; do
ask "(V)iew, (S)kip, (R)emove %s, (O)verwrite with %s, (Q)uit: [v/s/r/o/q] " "$file_type" "$file_type"
read c || break
case $c in
q|Q) exit 0;;
r|R) rm -v "$pacfile"; break ;;
......@@ -192,11 +193,9 @@ while IFS= read -u 3 -r -d '' pacfile; do
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 ;;
fi ;;
s|S) break ;;
*) ask "Invalid answer. Try again: [v/s/r/o/q] "; continue ;;
*) msg2 "Invalid answer." ;;
esac
done
fi
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment