Minor code improvement

This commit is contained in:
René Fuhry 2023-04-03 23:53:36 +02:00 committed by GitHub
parent 3a976e50b5
commit 792504c4fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

34
update
View File

@ -4,7 +4,7 @@
source "$HOME"/.config/update.conf
VER="2.0.1"
VER="2.0.2"
IGREEN="\033[0;92m" # Intense Green
IYELLOW="\033[0;93m" # Intense Red
NC="\033[0m" # Text Reset
@ -16,6 +16,13 @@ FINAL_COMMAND=""
trap interrupt_function INT
interrupt_function() {
echo "Interrupt has been detected"
sudo rm /var/lib/pacman/db.lck &> /dev/null
rm -r "$TMP" &> /dev/null
exit 1
}
Help() {
echo "Usage: update [OPTION]"
echo
@ -79,29 +86,25 @@ update_with_flatpak() {
flatpak list > "$TMP"/after-backup_"$DATE"/flatpak-after.txt
}
interrupt_function() {
echo "Interrupt has been detected"
sudo rm /var/lib/pacman/db.lck &> /dev/null
rm -r "$TMP" &> /dev/null
exit 1
}
[[ -z $1 ]] && before_backup && echo -e "${IGREEN}pre-backup complete${NC}" && update_with_pacman_wrapper
if [[ ${1:0:2} = -- ]]; then
case "${1:2}" in
help)
Help && exit 0;;
Help ;;
preview)
sudo pacman -Sy &> /dev/null && sudo pacman -Qu && exit 0;;
sudo pacman -Sy &> /dev/null && sudo pacman -Qu ;;
version)
echo "$VER" && exit 0;;
echo "$VER" ;;
?)
Help && exit 1;;
esac
else
before_backup && echo -e "${IGREEN}pre-backup complete${NC}"
exit 0
fi
while getopts 'fpagr' OPTIONS; do
before_backup && echo -e "${IGREEN}pre-backup complete${NC}"
while getopts 'fpagr' OPTIONS; do
case $OPTIONS in
f)
update_with_flatpak;;
@ -118,7 +121,6 @@ else
?)
Help && exit 1;;
esac
done
fi
done
after_backup && echo -e "${IGREEN}after-backup complete${NC}"