Check zero size of files correctly (#487)

from man test:
-s FILE
    FILE exists and has a size greater than zero

-z STRING
    the length of STRING is zero
This commit is contained in:
Katarina Durechova 2017-10-31 09:05:29 +01:00 committed by Michael Boelen
parent 8048b3d682
commit 09de901d11
2 changed files with 3 additions and 3 deletions

View File

@ -726,7 +726,7 @@
if [ $# -eq 0 ]; then ExitFatal "Missing parameter when calling FileIsEmpty function"; fi
EMPTY=0
LogText "Test: checking if file $1 is empty"
if [ -z $1 ]; then
if [ ! -s "$1" ]; then
LogText "Result: file $1 is empty"
EMPTY=1
return 0
@ -1489,7 +1489,7 @@
# Amazon EC2
if [ "${SHORT}" = "" ]; then
LogText "Test: checking specific files for Amazon"
if [ -f /etc/ec2_version -a ! -z /etc/ec2_version ]; then
if [ -f /etc/ec2_version -a -s /etc/ec2_version ]; then
SHORT="amazon-ec2"
else
LogText "Result: system not hosted on Amazon"

View File

@ -428,7 +428,7 @@
FOUND=0
FILE="/etc/ntp/step-tickers"
if [ -f ${FILE} ]; then
if [ -z ${FILE} ]; then
if [ ! -s "${FILE}" ]; then
LogText "Result: ${FILE} is empty. The step-tickers contain no configured NTP servers"
Display --indent 2 --text "- Checking NTP step-tickers file" --result "EMPTY FILE" --color YELLOW
ReportSuggestion ${TEST_NO} "Use step-tickers file for quicker time synchronization"