Correct script for multiple get

This commit is contained in:
Léo 2020-11-12 13:57:00 +01:00
parent 5b1b8cb614
commit 862a511b3a

View File

@ -7,8 +7,7 @@ set -euo pipefail
#######################################################################
# Curl function to be used
CURL="curl"
DEFAULT_ARGS_CURL=()
CURL=("curl")
# Defaults field to use. If equal to $UNSET will be oncsiedered as no set
URLPATH="/up"
@ -77,9 +76,9 @@ fi
function check_prerequisite()
{
if ! command -v $CURL &> /dev/null
if ! command -v ${CURL[0]} &> /dev/null
then
echo -e "${ROUGE}ERROR${STOPC}: $CURL could not be found."
echo -e "${ROUGE}ERROR${STOPC}: ${CURL[0]} could not be found."
echo "Aborting"
exit 2
fi
@ -227,7 +226,9 @@ then
[ ! "$GETPATH" = "$UNSET" ] && FULLURL+="$GETPATH"
FULLURL+="/$USERNAME/$FPATH"
[ ! "$GETPATHSUFFIX" = "$UNSET" ] && FULLURL+="$GETPATHSUFFIX"
ARGS+=("$FULLURL")
[ $VERB -gt 0 ] && echo "> $CURL ${ARGS[@]} $FULLURL -o $FPATH"
${CURL[@]} ${ARGS[@]} $FULLURL -o $FPATH
done
else
# Default args
@ -244,7 +245,8 @@ else
FULLURL="$URL"
[ ! "$URLPATH" = "$UNSET" ] && FULLURL+="$URLPATH"
ARGS+=("$FULLURL")
fi
[ $VERB -gt 0 ] && echo "> $CURL ${ARGS[@]}"
$CURL ${ARGS[@]} ${DEFAULT_ARGS_CURL[@]}
${CURL[@]} ${ARGS[@]}
fi