mirror of
https://github.com/arkenfox/user.js.git
synced 2025-05-01 06:23:34 +02:00
return empty string if download fails and return/exit if this happens
This commit is contained in:
parent
66b7aa7b89
commit
8d0f6443e6
1 changed files with 5 additions and 3 deletions
|
@ -107,7 +107,7 @@ Optional Arguments:
|
||||||
download_file () { # expects URL as argument ($1)
|
download_file () { # expects URL as argument ($1)
|
||||||
declare -r tf=$(mktemp)
|
declare -r tf=$(mktemp)
|
||||||
|
|
||||||
$DOWNLOAD_METHOD "${tf}" "$1" && echo "$tf" || return 1 # return the temp-filename or return error code 1
|
$DOWNLOAD_METHOD "${tf}" "$1" && echo "$tf" || echo '' # return the temp-filename or empty string on error
|
||||||
}
|
}
|
||||||
|
|
||||||
open_file () { #expects one argument: file_path
|
open_file () { #expects one argument: file_path
|
||||||
|
@ -196,6 +196,7 @@ update_updater () {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
declare -r tmpfile=$(download_file 'https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/updater.sh')
|
declare -r tmpfile=$(download_file 'https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/updater.sh')
|
||||||
|
[ -z "${tmpfile}" ] && echo -e "${RED}Error! Could not download updater.sh${NC}" && return 1 # check if download failed
|
||||||
|
|
||||||
if [[ $(get_updater_version "${SCRIPT_DIR}/updater.sh") < $(get_updater_version "${tmpfile}") ]]; then
|
if [[ $(get_updater_version "${SCRIPT_DIR}/updater.sh") < $(get_updater_version "${tmpfile}") ]]; then
|
||||||
if [ $UPDATE = 'check' ]; then
|
if [ $UPDATE = 'check' ]; then
|
||||||
|
@ -249,8 +250,8 @@ remove_comments () { # expects 2 arguments: from-file and to-file
|
||||||
|
|
||||||
# Applies latest version of user.js and any custom overrides
|
# Applies latest version of user.js and any custom overrides
|
||||||
update_userjs () {
|
update_userjs () {
|
||||||
declare -r newfile="$(download_file 'https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/user.js')" ret="$?"
|
declare -r newfile="$(download_file 'https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/user.js')"
|
||||||
[ "$ret" -ne 0 ] && echo -e "${RED}Error! Could not download user.js${NC}" && return 1
|
[ -z "${newfile}" ] && echo -e "${RED}Error! Could not download user.js${NC}" && return 1 # check if download failed
|
||||||
|
|
||||||
echo -e "Please observe the following information:
|
echo -e "Please observe the following information:
|
||||||
Firefox profile: ${ORANGE}$(pwd)${NC}
|
Firefox profile: ${ORANGE}$(pwd)${NC}
|
||||||
|
@ -370,6 +371,7 @@ if [ $# != 0 ]; then
|
||||||
;;
|
;;
|
||||||
r)
|
r)
|
||||||
tfile=$(download_file 'https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/user.js')
|
tfile=$(download_file 'https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/user.js')
|
||||||
|
[ -z "${tfile}" ] && echo -e "${RED}Error! Could not download user.js${NC}" && exit 1 # check if download failed
|
||||||
mv $tfile "${tfile}.js"
|
mv $tfile "${tfile}.js"
|
||||||
echo -e "${ORANGE}Warning: user.js was saved to temporary file ${tfile}.js${NC}"
|
echo -e "${ORANGE}Warning: user.js was saved to temporary file ${tfile}.js${NC}"
|
||||||
open_file "${tfile}.js"
|
open_file "${tfile}.js"
|
||||||
|
|
Loading…
Add table
Reference in a new issue