fix common mistake, while the variable assignment takes place before the local declaration, what leads into unexpected value
This commit is contained in:
parent
d5476d0665
commit
ad243457e3
|
@ -8,19 +8,20 @@
|
||||||
# Parameters: %url% %directory%
|
# Parameters: %url% %directory%
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
function download() {
|
function download() {
|
||||||
local DEST="${2}"
|
local DEST FILENAME RESULT URL
|
||||||
local FILENAME="${1##*/}"
|
DEST="${2}"
|
||||||
local URL="${1}"
|
FILENAME="${1##*/}"
|
||||||
|
URL="${1}"
|
||||||
if isSet DEST; then
|
if isSet DEST; then
|
||||||
local DEST="${DEST}/${FILENAME}"
|
DEST="${DEST}/${FILENAME}"
|
||||||
else
|
else
|
||||||
local DEST="./${FILENAME}"
|
DEST="./${FILENAME}"
|
||||||
fi
|
fi
|
||||||
echo -ne " ${STAR_GREEN} ${FILENAME}: "
|
echo -ne " ${STAR_GREEN} ${FILENAME}: "
|
||||||
wget --progress=dot -c -t ${FETCHTRIES} -T ${FETCHTIMEOUT} -O "${DEST}" \
|
wget --progress=dot -c -t ${FETCHTRIES} -T ${FETCHTIMEOUT} -O "${DEST}" \
|
||||||
${URL} 2>&1 | grep --line-buffered "%" | sed -u -e "s/[\.\,]//g" | \
|
${URL} 2>&1 | grep --line-buffered "%" | sed -u -e "s/[\.\,]//g" | \
|
||||||
awk '{printf("\b\b\b\b%4s", $2)}'
|
awk '{printf("\b\b\b\b%4s", $2)}'
|
||||||
local RESULT=${PIPESTATUS[0]}
|
RESULT=${PIPESTATUS[0]}
|
||||||
echo -ne "\b\b\b\b"
|
echo -ne "\b\b\b\b"
|
||||||
if [[ ${RESULT} -ne 0 ]]; then
|
if [[ ${RESULT} -ne 0 ]]; then
|
||||||
logOutput "Unable to download ${URL}! Exit code: ${RESULT}"
|
logOutput "Unable to download ${URL}! Exit code: ${RESULT}"
|
||||||
|
@ -36,9 +37,10 @@ function download() {
|
||||||
# Parameters: %directory%
|
# Parameters: %directory%
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
function makeDirectory() {
|
function makeDirectory() {
|
||||||
local OUTPUT=$(install -d "${@}" 2>&1)
|
local OUTPUT RESULT
|
||||||
local RESULT=${?}
|
OUTPUT=$(install -d "${@}" 2>&1)
|
||||||
if [[ ${RESULT} -ne 0 ]]; then
|
RESULT=${?}
|
||||||
|
if [ ${RESULT} -ne 0 ]; then
|
||||||
logOutput "${OUTPUT}"
|
logOutput "${OUTPUT}"
|
||||||
fi
|
fi
|
||||||
return ${RESULT}
|
return ${RESULT}
|
||||||
|
@ -49,10 +51,11 @@ function makeDirectory() {
|
||||||
# Parameters: %source% %target%
|
# Parameters: %source% %target%
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
function makeLink() {
|
function makeLink() {
|
||||||
local DESTDIR="${2%/*}"
|
local DESTDIR OUTPUT RESULT
|
||||||
|
DESTDIR="${2%/*}"
|
||||||
[[ ! -d ${DESTDIR} ]] && makeDirectory "${DESTDIR}"
|
[[ ! -d ${DESTDIR} ]] && makeDirectory "${DESTDIR}"
|
||||||
local OUTPUT=$(ln -sfn "${1}" "${2}" 2>&1)
|
OUTPUT=$(ln -sfn "${1}" "${2}" 2>&1)
|
||||||
local RESULT=${?}
|
RESULT=${?}
|
||||||
if [[ ${RESULT} -ne 0 ]]; then
|
if [[ ${RESULT} -ne 0 ]]; then
|
||||||
logOutput "${OUTPUT}"
|
logOutput "${OUTPUT}"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue