Skip to content

Commit 9427216

Browse files
committed
Add comments to return statements to clarify
1 parent 11090fc commit 9427216

1 file changed

Lines changed: 27 additions & 9 deletions

File tree

msctl

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,10 @@ getJavaMemory() {
358358
serverRunning() {
359359
# Try to determine if the world is running.
360360
if [ $(getJavaPID "$1") -gt 0 ]; then
361+
# Return a true value (success).
361362
return 0
362363
else
364+
# Return a false value (failure).
363365
return 1
364366
fi
365367
}
@@ -547,8 +549,10 @@ isWorldEnabled() {
547549
local WORLDS
548550
WORLDS=$(getEnabledWorlds)
549551
if [ -n "$1" ] && listContains "$1" "$WORLDS"; then
552+
# Return a true value (success).
550553
return 0
551554
else
555+
# Return a false value (failure).
552556
return 1
553557
fi
554558
}
@@ -563,8 +567,10 @@ isWorldDisabled() {
563567
local WORLDS
564568
WORLDS=$(getDisabledWorlds)
565569
if [ -n "$1" ] && listContains "$1" "$WORLDS"; then
570+
# Return a true value (success).
566571
return 0
567572
else
573+
# Return a false value (failure).
568574
return 1
569575
fi
570576
}
@@ -579,8 +585,10 @@ isWorldAvailable() {
579585
local WORLDS
580586
WORLDS=$(getAvailableWorlds)
581587
if [ -n "$1" ] && listContains "$1" "$WORLDS"; then
588+
# Return a true value (success).
582589
return 0
583590
else
591+
# Return a false value (failure).
584592
return 1
585593
fi
586594
}
@@ -1161,25 +1169,29 @@ createLockFile() {
11611169
# LOCKFILE exists, check to see if its process is running.
11621170
ps -p $PID >/dev/null 2>&1
11631171
if [ $? -eq 0 ]; then
1164-
# LOCKFILE exists and the process is running, return FALSE.
1172+
# LOCKFILE exists and the process is running.
1173+
# Return a false value (failure).
11651174
return 1
11661175
else
11671176
# Process not found assume it is not running.
11681177
echo $$ >$LOCKFILE
11691178
if [ $? -ne 0 ]; then
1170-
# Error creating LOCKFILE, return FALSE.
1179+
# Error creating LOCKFILE.
1180+
# Return a false value (failure).
11711181
return 1
11721182
fi
11731183
fi
11741184
else
11751185
# LOCKFILE does not exists.
11761186
echo $$ >$LOCKFILE
11771187
if [ $? -ne 0 ]; then
1178-
# Error creating LOCKFILE, return FALSE.
1188+
# Error creating LOCKFILE.
1189+
# Return a false value (failure).
11791190
return 1
11801191
fi
11811192
fi
1182-
# Success creating LOCKFILE, return TRUE.
1193+
# Success creating LOCKFILE.
1194+
# Return a true value (success).
11831195
return 0
11841196
}
11851197

@@ -1440,10 +1452,10 @@ worldBackup() {
14401452
# Make sure that the backup location exists.
14411453
if ! mkdir -p "$BACKUP_LOCATION"; then
14421454
echo "Error creating backup dir $BACKUP_LOCATION"
1455+
# Return a false value (failure).
14431456
return 1
14441457
fi
1445-
# Synchronize the mirror image of the world prior to closing, if
1446-
# required.
1458+
# Synchronize the mirror image of the world prior to closing, if required.
14471459
if [ $ENABLE_MIRROR -eq 1 ] && [ -L "$WORLDS_LOCATION/$1/$1" ] && [ -d "$MIRROR_PATH/$1" ]; then
14481460
syncMirrorImage $1
14491461
fi
@@ -1474,15 +1486,18 @@ worldBackup() {
14741486
# Create the backup.
14751487
if ! $RDIFF_BACKUP -v5 --print-statistics $EXCLUDE_OPTION "$WORLDS_LOCATION/$1" "$BACKUP_LOCATION/$1" >>"$BACKUP_LOG"; then
14761488
echo "Error doing backup of world $1"
1489+
# Return a false value (failure).
14771490
return 1
14781491
fi
14791492
# Cleanup old backups.
14801493
if [ $BACKUP_DURATION -gt 0 ]; then
14811494
if ! $RDIFF_BACKUP --remove-older-than ${BACKUP_DURATION}D --force "$BACKUP_LOCATION/$1" >>"$BACKUP_LOG"; then
14821495
echo "Error cleaning old backups of world $1"
1496+
# Return a false value (failure).
14831497
return 1
14841498
fi
14851499
fi
1500+
# Return a true value (success).
14861501
return 0
14871502
}
14881503

@@ -1521,10 +1536,12 @@ worldBackupRestore() {
15211536
else
15221537
echo "Restoring backup failed: $1 $2"
15231538
rm -rf "$TARGET_TMP"
1539+
# Return a false value (failure).
15241540
return 1
15251541
fi
15261542
else
15271543
echo "No backups found for world $1"
1544+
# Return a false value (failure).
15281545
return 1
15291546
fi
15301547
}
@@ -1983,7 +2000,7 @@ queryDetailedStatusJSON() {
19832000
queryNumUsers() {
19842001
local NUM_USERS
19852002
NUM_USERS=$(queryStatus $1 | cut -f6)
1986-
# Return 0 if query server not available
2003+
# Return 0 users if query server not available.
19872004
[ -z "$NUM_USERS" ] && NUM_USERS=0
19882005
printf "$NUM_USERS"
19892006
}
@@ -2418,9 +2435,10 @@ OVERVIEWER_URL=$(getDefaultsValue 'mscs-overviewer-url' 'http://overviewer.org')
24182435
MAPS_LOCATION=$(getDefaultsValue 'mscs-maps-location' $LOCATION'/maps')
24192436
MAPS_URL=$(getDefaultsValue 'mscs-maps-url' 'http://minecraft.server.com/maps')
24202437

2421-
# allow function importing via source command for tests
2438+
# Allow function importing via source command for tests.
24222439
if printf $0 | grep -qs "runtests\.sh"; then
2423-
# file was sourced, don't execute below here
2440+
# File was sourced, don't execute below here.
2441+
# Return a true value (success).
24242442
return 0
24252443
fi
24262444

0 commit comments

Comments
 (0)