From 8c34b5efe171e9f3b6daf3cefd319872684d121f Mon Sep 17 00:00:00 2001 From: onefang Date: Tue, 13 Aug 2019 01:00:58 +1000 Subject: Stop using num2name() in scripts. Turns out I was feeding "01" to it, so that's why it thought things where octal, and "01" is the result we wanted anyway. --- scripts/backup-sims.sh | 5 ++--- scripts/common.sh | 6 ++---- scripts/install/create_sim.sh | 3 +-- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/scripts/backup-sims.sh b/scripts/backup-sims.sh index cadb9a2..06cb780 100755 --- a/scripts/backup-sims.sh +++ b/scripts/backup-sims.sh @@ -5,10 +5,9 @@ getPrgDir for i in $(seq -w 1 99) do - j=$(num2name ${i}) - if [ -e "${PRGDIR}/../../config/${j}" ] + if [ -e "${PRGDIR}/../../config/sim${i}" ] then - pushd ${PRGDIR}/../../config/${j} >/dev/null + pushd ${PRGDIR}/../../config/sim${i} >/dev/null # Find out the size of the last backup, base our later sleep on that, but do it now before backup-sim packs it away. sizeSleep=`sleepPerSize o "$(getSimName ${i})"` ./backup-sim diff --git a/scripts/common.sh b/scripts/common.sh index 9d985f2..6aeb8b5 100755 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -28,9 +28,7 @@ getPrgDir() # name=$(num2name 1) num2name() { - # Using a string format, coz using a number format ends with an octal error, coz 08 isn't a valid octal number. - # Why isn't octal dead already? - printf 'sim%02s' "$1" + /usr/bin/printf 'sim%02d' "$1" } @@ -46,7 +44,7 @@ sanitize() # name=$(getSimName 1) getSimName() { - grep "RegionName" ${PRGDIR}/../../config/$(num2name $1)/*.ini | head -n 1 | cut -d '"' -f 2 + grep "RegionName" ${PRGDIR}/../../config/sim$1/*.ini | head -n 1 | cut -d '"' -f 2 } diff --git a/scripts/install/create_sim.sh b/scripts/install/create_sim.sh index 055f802..0aa0941 100755 --- a/scripts/install/create_sim.sh +++ b/scripts/install/create_sim.sh @@ -13,8 +13,7 @@ cd ${OS_PATH}/config k=0 for i in $(seq -w 1 99) do - j=$(num2name "$i") - if [ -e "$j" ] + if [ -e "sim$j" ] then k=$i fi -- cgit v1.1