Skip to content

Commit

Permalink
Merge pull request #58 from Akianonymus/fix
Browse files Browse the repository at this point in the history
upload.sh: Fix some mistakes of 5aa3fb5 | Fix #57
  • Loading branch information
labbots committed May 21, 2020
2 parents ae367c3 + 722afc9 commit 533bdcc
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 24 deletions.
14 changes: 7 additions & 7 deletions google-oauth2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ Usage:
[[ ${2} = update ]] && UPDATE="_update_config"

UTILS_FILE="${UTILS_FILE:-./utils.sh}"
if [[ -r ${UTILS_FILE} ]]; then
# shellcheck source=/dev/null
source "${UTILS_FILE}" || { printf "Error: Unable to source utils file ( %s ) .\n" "${UTILS_FILE}" && exit 1; }
else
printf "Error: Utils file ( %s ) not found\n" "${UTILS_FILE}"
exit 1
fi
if [[ -r ${UTILS_FILE} ]]; then
# shellcheck source=/dev/null
source "${UTILS_FILE}" || { printf "Error: Unable to source utils file ( %s ) .\n" "${UTILS_FILE}" && exit 1; }
else
printf "Error: Utils file ( %s ) not found\n" "${UTILS_FILE}"
exit 1
fi

if ! _is_terminal; then
DEBUG="true"
Expand Down
4 changes: 2 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ _full_path() {
# Globals: None
# Arguments: 3
# ${1} = "branch" or "release"
# ${2} = repo name e.g labbots/google-drive-upload
# ${3} = branch name
# ${2} = branch name or release name
# ${3} = repo name e.g labbots/google-drive-upload
# Result: print fetched sha
###################################################
_get_latest_sha() {
Expand Down
23 changes: 10 additions & 13 deletions upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -488,15 +488,11 @@ _setup_arguments() {

SHORTOPTS=":qvVi:sp:odf:ShuUr:C:Dz:-:"
while getopts "${SHORTOPTS}" OPTION; do
_check_default() {
eval "${2}" "$([[ ${2} = default* ]] && printf "%s\n" "${3}")"
}
_check_config() {
if [[ -r ${1} ]]; then
CONFIG="${1}" && UPDATE_DEFAULT_CONFIG="true"
else
{ [[ ${1} = default* ]] && UPDATE_DEFAULT_CONFIG="true"; } || :
{ [[ -r ${2} ]] && CONFIG="${2}"; } || {
printf "Error: Given config file (%s) doesn't exist/not readable,..\n" "${1}" 1>&2 && exit 1
fi
}
}
case "${OPTION}" in
-)
Expand Down Expand Up @@ -525,13 +521,13 @@ _setup_arguments() {
;;
root-dir)
_check_longoptions
_check_default "${!OPTIND}" "ROOTDIR=${!OPTIND/default=/}" "UPDATE_DEFAULT_ROOTDIR=_update_config"
ROOTDIR="${!OPTIND/default=/}"
{ [[ ${!OPTIND} = default* ]] && UPDATE_DEFAULT_ROOTDIR="_update_config"; } || :
OPTIND=$((OPTIND + 1))

;;
config)
_check_longoptions
_check_default "${!OPTIND}" "_check_config" "${!OPTIND/default=/}"
_check_config "${!OPTIND}" "${!OPTIND/default=/}"
OPTIND=$((OPTIND + 1))
;;
save-info)
Expand Down Expand Up @@ -607,10 +603,11 @@ _setup_arguments() {
FOLDERNAME="${OPTARG}"
;;
r)
_check_default "${OPTARG}" "ROOTDIR=${OPTARG/default=/}" "UPDATE_DEFAULT_ROOTDIR=_update_config"
ROOTDIR="${OPTARG/default=/}"
{ [[ ${OPTARG} = default* ]] && UPDATE_DEFAULT_ROOTDIR="_update_config"; } || :
;;
z)
_check_default "${OPTARG}" "_check_config" "${OPTARG/default=/}"
_check_config "${OPTARG}" "${OPTARG/default=/}"
;;
i)
LOG_FILE_ID="${OPTARG}"
Expand Down Expand Up @@ -1134,4 +1131,4 @@ main() {
"${QUIET:-_print_center}" "normal" " Time Elapsed: ""$((DIFF / 60))"" minute(s) and ""$((DIFF % 60))"" seconds. " "="
}

main "${@}"
main "${@}"
4 changes: 2 additions & 2 deletions utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ _full_path() {
# Globals: None
# Arguments: 3
# ${1} = "branch" or "release"
# ${2} = repo name e.g labbots/google-drive-upload
# ${3} = branch name
# ${2} = branch name or release name
# ${3} = repo name e.g labbots/google-drive-upload
# Result: print fetched sha
###################################################
_get_latest_sha() {
Expand Down

0 comments on commit 533bdcc

Please sign in to comment.