diff --git a/inxi b/inxi index 3a33657..d51bf25 100755 --- a/inxi +++ b/inxi @@ -1,7 +1,7 @@ #!/bin/bash ######################################################################## #### Script Name: inxi -#### version: 0.5.23 +#### version: 0.5.24 #### Date: November 11 2008 ######################################################################## #### inxi is a fork of infobash, the original bash sys info script by locsmif @@ -709,26 +709,27 @@ print_version_info() # note that $1 must end in / to properly construct the url path script_self_updater() { + local wget_error=0 print_screen_output "Starting $SCRIPT_NAME self updater." print_screen_output "Currently running $SCRIPT_NAME version number: $SCRIPT_VERSION_NUMBER" print_screen_output "Updating $SCRIPT_NAME in $SCRIPT_PATH using $2 as download source..." - # first test if path is good - wget -q --spider $1$SCRIPT_NAME - # then do the actual download, need to make sure it's good because we're -O overwriting file - if [[ $? -eq 0 ]];then - wget -q -O $SCRIPT_PATH/$SCRIPT_NAME $1$SCRIPT_NAME - if [[ $? -eq 0 ]];then + # first test if path is good, need to make sure it's good because we're -O overwriting file + wget -q --spider $1$SCRIPT_NAME || wget_error=$? + # then do the actual download + if [[ $wget_error -eq 0 ]];then + wget -q -O $SCRIPT_PATH/$SCRIPT_NAME $1$SCRIPT_NAME || wget_error=$? + if [[ $wget_error -eq 0 ]];then SCRIPT_VERSION_NUMBER=$( grep -im 1 'version:' $SCRIPT_PATH/$SCRIPT_NAME | gawk '{print $3}' ) print_screen_output "Successfully updated to $2 version: $SCRIPT_VERSION_NUMBER\nTo run the new version, just start $SCRIPT_NAME again." exit 0 - else - error_handler 8 "$?" fi - else + fi + # now run the error handlers on any wget failure + if [[ $wget_error -gt 0 ]];then if [[ $2 == 'svn server' ]];then - error_handler 8 "$?" + error_handler 8 "$wget_error" elif [[ $2 == 'alt server' ]];then - error_handler 10 "$OPTARG" + error_handler 10 "$1" else error_handler 12 "$1" fi