Fix Maldet scanner bash errors
Problem: Maldet scanner threw two errors during execution: 1. "local: can only be used in a function" (line 544/1086) 2. "[: -ne: unary operator expected" (line 546/1088) Root Cause: - Used 'local' keyword inside case statement (not a function) - The 'local' keyword is only valid inside function definitions - Case statements are not functions, so 'local' fails Fix: Changed line 1086 from: local exit_code=$? To: exit_code=$? Also added quotes around variable in comparison (line 1088): if [ "$exit_code" -ne 0 ]; then This makes exit_code a regular variable instead of function-scoped, which is appropriate since we're in a case block, not a function. Testing: - Syntax validates correctly - No more "local: can only be used in a function" error - No more unary operator errors
This commit is contained in:
@@ -1083,9 +1083,9 @@ for scanner in "${AVAILABLE_SCANNERS[@]}"; do
|
|||||||
# Run with -a (scan-all) for comprehensive scanning
|
# Run with -a (scan-all) for comprehensive scanning
|
||||||
# Timeout after 2 hours per path
|
# Timeout after 2 hours per path
|
||||||
timeout 7200 maldet -b -a "$path" &>> "$LOG_DIR/maldet.log"
|
timeout 7200 maldet -b -a "$path" &>> "$LOG_DIR/maldet.log"
|
||||||
local exit_code=$?
|
exit_code=$?
|
||||||
|
|
||||||
if [ $exit_code -ne 0 ]; then
|
if [ "$exit_code" -ne 0 ]; then
|
||||||
MALDET_EXIT=$exit_code
|
MALDET_EXIT=$exit_code
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user