Fixed channeldown.sh to work with double digit dirs.

This commit is contained in:
Justin Emter
2018-01-17 09:40:59 -08:00
parent fa1d604d0d
commit 3561f6811e

View File

@@ -72,19 +72,35 @@ if [ "${#CHANNEL_DIR_ARR[@]}" -gt 1 ]; then
# Now that the prevchannel is stored in a var, loop through channels and find prev channel & increment
for ((i = ${#CHANNEL_DIR_ARR[@]};i >= 1;i--)); do
NEXT_CHANNEL_NUM=$i
if [[ ${i} == *"$PREV_CHANNEL"* ]]; then
echo "+++++ Found previous channel, incrementing by 1."
PREV_CHANNEL_FOUND=true
PREV_CHANNEL_DIR=${CHANNEL_DIR_ARR[i-1]}
continue
if [ "${i}" -gt 9 ]; then
if [[ ${i} == *"$PREV_CHANNEL"* ]]; then
echo "+++++ Found previous channel, decreasing by 1."
PREV_CHANNEL_FOUND=true
PREV_CHANNEL_DIR="${CHANNEL_DIR_ARR[i-1]}"
continue
fi
else
if [[ "0"${i} == *"$PREV_CHANNEL"* ]]; then
echo "+++++ Found previous channel, decreasing by 1."
PREV_CHANNEL_FOUND=true
PREV_CHANNEL_DIR="${CHANNEL_DIR_ARR[i-1]}"
continue
fi
fi
if [ "$PREV_CHANNEL_FOUND" = true ] ; then
echo "PREV_CHANNEL_FOUND"
echo "$PREV_CHANNEL_FOUND"
NEXT_CHANNEL=${CHANNEL_DIR_ARR[i-1]}
NEXT_CHANNEL="${CHANNEL_DIR_ARR[i-1]}"
break