Skip to content
This repository was archived by the owner on Feb 23, 2026. It is now read-only.

Commit 3562b3e

Browse files
authored
-u warns on permission denied; update check on exit
downloading the script in /tmp/adl is not ideal but the file is small
1 parent 16b27a4 commit 3562b3e

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

adl

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ clean_exit() {
7979
[[ -e "$FZF_FILE" ]] && rm "$FZF_FILE"
8080
reset_all_vars
8181
color_print "\nThank you for using adl ✨! \nExiting."
82+
check_for_updates
8283
}
8384

8485
# An array of anime that end with a fullstop/period/dot
@@ -920,29 +921,34 @@ updater() { #{{{
920921
[[ "$updater_ans" == "repeat_prompt" ]] && read -p "Not an option. Retype your choice: " updater_ans
921922
case "$updater_ans" in
922923
[yY]*)
923-
# color_prompt "\nadl can be updated from master or develop. Which one do you choose? [M/d]: "
924-
# read -r source_ans
925-
# case "$source_ans" in
926-
# ""|"M"|"m")
927-
# source="master"
928-
# wget -q --show-progress "https://raw.githubusercontent.com/RaitaroH/adl/master/adl" -O "$DIR/$FILE" ;;
929-
# "d"|"D")
930-
# source="develop"
931-
# wget -q --show-progress "https://raw.githubusercontent.com/RaitaroH/adl/develop/adl" -O "$DIR/$FILE" ;;
932-
# *)
933-
# color_print "Not an actual option. Exiting..."
934-
# exit 1 ;;
935-
# esac
936-
wget -q --show-progress "https://raw.githubusercontent.com/RaitaroH/adl/master/adl" -O "$DIR/$FILE"
937-
color_print "\n✓ Update from master is complete."
924+
if wget --quiet "https://raw.githubusercontent.com/RaitaroH/adl/master/adl" -O "$DIR/$FILE"; then
925+
color_print "\n✓ Update from master is complete."
926+
else
927+
echo -e "$_cr""Update failed. Try updating from AUR, or use 'sudo adl -u'"
928+
fi
938929
break ;;
939930
""|[nN]*)
940931
color_print "Update aborted."
941932
break ;;
942933
*) updater_ans="repeat_prompt" ;;
943934
esac
944935
done
945-
} #}}}
936+
}
937+
check_for_updates() {
938+
local git_file="/tmp/adl"
939+
if [[ ! -e "$git_file" ]]; then
940+
wget --quiet "https://raw.githubusercontent.com/RaitaroH/adl/master/adl" -O "$git_file"
941+
fi
942+
local thisv gitv
943+
# using sed to make the numbers integers
944+
thisv=$(print_version | awk '{print $2}' | sed 's/\.//g')
945+
# it is #3 here because ## are not removed
946+
gitv=$(grep 'Version' "$git_file" | awk '{print $3}' | sed 's/\.//g')
947+
if [[ "$gitv" -gt "$thisv" ]]; then
948+
printf "$_cr%s$_cd\n" "adl is outdated! Update using 'adl -u', or however you can."
949+
fi
950+
}
951+
#}}}
946952

947953
arguments() { #{{{
948954
# check if option is interpreted as argument for previous option; match getopt error format

0 commit comments

Comments
 (0)