Jelajahi Sumber

Simplifying counting

Why make it simple when you can make it harder !
> Removing conditional functions for additions, by setting all variables to 0 before starting counting.
> Removing "else, set to 0", as 0 is now the default state
lrob 10 tahun lalu
induk
melakukan
eb67a375ad
1 mengubah file dengan 5 tambahan dan 9 penghapusan
  1. 5 9
      functions/logs.sh

+ 5 - 9
functions/logs.sh

@@ -50,6 +50,9 @@ if [ $(find "${scriptlogdir}"/ -type f -mtime +${logdays}|wc -l) -ne "0" ]; then
 	if [ -n "${consolelog}" ]; then
 	if [ -n "${consolelog}" ]; then
 		find "${consolelogdir}"/ -type f -mtime +${logdays}|tee >> "${scriptlog}"
 		find "${consolelogdir}"/ -type f -mtime +${logdays}|tee >> "${scriptlog}"
 	fi
 	fi
+	# Counting
+	# Setting up variables
+	scriptcount="0" ; consolecount="0" ; gamecount="0" ; srcdscount="0" ; smcount="0" ; ulxcount="0" ; darkrpcount="0"
 	# Retrocompatibility, for logs directly in /log folder 
 	# Retrocompatibility, for logs directly in /log folder 
 	# Count how many script logfiles will be removed
 	# Count how many script logfiles will be removed
 	if [ "${engine}" == "unreal2" ]||[ "${engine}" == "source" ]; then
 	if [ "${engine}" == "unreal2" ]||[ "${engine}" == "source" ]; then
@@ -58,19 +61,12 @@ if [ $(find "${scriptlogdir}"/ -type f -mtime +${logdays}|wc -l) -ne "0" ]; then
 	# Count how many script logfiles will be removed
 	# Count how many script logfiles will be removed
 	scriptcount=$(find "${scriptlogdir}"/ -type f -mtime +${logdays}|wc -l)
 	scriptcount=$(find "${scriptlogdir}"/ -type f -mtime +${logdays}|wc -l)
 	echo "${consolelog}"
 	echo "${consolelog}"
-	# Count how many console logfiles will be removed
+	# Count how many console logfiles will be removed, if those logs exist
 	if [ -n "${consolelog}" ]; then
 	if [ -n "${consolelog}" ]; then
 		consolecount=$(find "${consolelogdir}"/ -type f -mtime +${logdays}|wc -l)
 		consolecount=$(find "${consolelogdir}"/ -type f -mtime +${logdays}|wc -l)
-	else
-		consolecount=0
 	fi
 	fi
 	# Count total amount of files to remove
 	# Count total amount of files to remove
-	count=$((${scriptcount} + ${consolecount}))
-	if [ "${engine}" == "unreal2" ]||[ "${engine}" == "source" ]; then
-		count=$((${scriptcount} + ${consolecount} + ${gamecount}))
-	else
-		count=$((${scriptcount} + ${consolecount}))
-	fi
+	count=$((${scriptcount} + ${consolecount} + ${gamecount} + ${srcdscount} + ${smcount} + ${ulxcount} + ${darkrpcount}))
 
 
 	# Removing logfiles
 	# Removing logfiles
 	if [ "${engine}" == "unreal2" ]||[ "${engine}" == "source" ]; then
 	if [ "${engine}" == "unreal2" ]||[ "${engine}" == "source" ]; then