Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
do not exit when update always is also called (#105)
Browse files Browse the repository at this point in the history
do not exit when update always is also called
  • Loading branch information
Heavybullets8 authored May 13, 2023
1 parent 95de493 commit 6fbeeef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions functions/self_update/handler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
self_update_handler() {
export no_config
export major_self_update
export update_always=false
local args=("$@")
local SELFUPDATE__SELFUPDATE__always
local SELFUPDATE__SELFUPDATE__when_updating
Expand All @@ -20,8 +21,10 @@ self_update_handler() {
read_ini "config.ini" --prefix SELFUPDATE

# Check if always or when_updating is set to true in the config file
if { [[ "${SELFUPDATE__SELFUPDATE__always}" == "true" ]] ||
{ [[ "${SELFUPDATE__SELFUPDATE__when_updating}" == "true" ]] && [[ "${args[0]}" == "update" ]]; }; }; then
if [[ "${SELFUPDATE__SELFUPDATE__always}" == "true" ]]; then
self_update=true
update_always=true
elif { [[ "${SELFUPDATE__SELFUPDATE__when_updating}" == "true" ]] && [[ "${args[0]}" == "update" ]]; }; then
self_update=true
fi

Expand All @@ -31,9 +34,8 @@ self_update_handler() {
fi

# Update the script if --self-update/self-update/-U is passed
# dont update if --no-self-update is passed
if [[ $self_update == true ]]; then
self_update
fi
}
export -f self_update_handler
export -f self_update_handler
2 changes: 1 addition & 1 deletion functions/self_update/self_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ self_update() {
chmod +x "$script_name" ; chmod +x "$script_path"/bin/heavyscript 2>/dev/null

# Check if there are any arguments left
if [[ -z ${args[*]} ]]; then
if [[ -z ${args[*]} && $update_always == false ]]; then
echo -e "No more arguments, exiting..\n\n" && exit
fi
# Check if the script was updated, and if so, run the new version
Expand Down

0 comments on commit 6fbeeef

Please sign in to comment.