From 22c1a395af7f431fc2fa5ae77628b305fdcd1721 Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Wed, 17 Apr 2019 10:04:40 +0200 Subject: [PATCH] update check will always print something --- zsh/bin/update | 36 ++++++++++++++++++++++++------------ zshrc | 2 +- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/zsh/bin/update b/zsh/bin/update index 58183e6..4d8920b 100755 --- a/zsh/bin/update +++ b/zsh/bin/update @@ -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,18 +290,27 @@ 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 - case $1 in; + while [ $# -gt 0 ]; do - "system") update-system;; - "rust") update-rust;; - "npm") update-npm;; - "dotfiles") update-dotfiles;; - "neovim") update-neovim;; - "check") _check_date_if_format;; + case $1 in; - esac + "system") update-system;; + "rust") update-rust;; + "npm") update-npm;; + "dotfiles") update-dotfiles;; + "neovim") update-neovim;; + "check") _check_date_if_format force;; + "startup") _check_date_if_format;; + + esac + + shift + + done fi diff --git a/zshrc b/zshrc index 7da7209..1df5170 100644 --- a/zshrc +++ b/zshrc @@ -23,4 +23,4 @@ if [ -f $DOTFILES/zsh/extraconfig.zsh ]; then source $DOTFILES/zsh/extraconfig.zsh fi -update check +update startup