update check will always print something

This commit is contained in:
Thomas Forgione 2019-04-17 10:04:40 +02:00
parent abb4a02a9a
commit 22c1a395af
No known key found for this signature in database
GPG Key ID: 203DAEA747F48F41
2 changed files with 25 additions and 13 deletions

View File

@ -4,7 +4,7 @@ _check_date_if_format() {
local format=`_date_format`
if [ "$format" != "" ]; then
_check_date $format
_check_date $format $1
fi
}
@ -60,7 +60,7 @@ _check_date() {
if [ "$new_date" != "$old_date" ]; then
_sentence not_updated
elif [ "$UPDATE_CHECK_ALWAYS" = "true" ]; then
elif [ "$UPDATE_CHECK_ALWAYS" = "true" ] || [ "$2" = "force" ]; then
_sentence updated
fi
}
@ -71,8 +71,7 @@ update-system() {
sudoresult=$(sudo -nv 2>&1)
if [ $? -eq 0 ]; then
echo "\033[33;1m=== You are not a sudoer, skipping system update... ===\033[0m"
return 1
# Nothing to do
elif echo $sudoresult | grep -q '^sudo:'; then
echo "\033[32;1m=== Starting system update, please enter your password ===\033[0m"
sudo true
@ -254,6 +253,10 @@ update-neovim() {
echo "\033[32;1m=== Neovim updated in $formatted ===\033[0m"
}
_print_help() {
echo
}
main() {
if [ $# -eq 0 ]; then
@ -287,8 +290,12 @@ main() {
formatted=`date -ud "@$seconds" +'%H hours %M minutes %S seconds'`
echo "\033[32;1m=== Update finished in $formatted ===\033[0m"
_check_date_if_format force
else
while [ $# -gt 0 ]; do
case $1 in;
"system") update-system;;
@ -296,10 +303,15 @@ main() {
"npm") update-npm;;
"dotfiles") update-dotfiles;;
"neovim") update-neovim;;
"check") _check_date_if_format;;
"check") _check_date_if_format force;;
"startup") _check_date_if_format;;
esac
shift
done
fi
}

2
zshrc
View File

@ -23,4 +23,4 @@ if [ -f $DOTFILES/zsh/extraconfig.zsh ]; then
source $DOTFILES/zsh/extraconfig.zsh
fi
update check
update startup