diff --git a/lib/common-functions.sh b/lib/common-functions.sh index 7bdd02d..047eb82 100755 --- a/lib/common-functions.sh +++ b/lib/common-functions.sh @@ -236,6 +236,7 @@ format_duration() { # Check if command exists command_exists() { + [ -z "$1" ] && return 1 command -v "$1" >/dev/null 2>&1 } diff --git a/lib/php-detector.sh b/lib/php-detector.sh index 87e611c..8a64ee9 100644 --- a/lib/php-detector.sh +++ b/lib/php-detector.sh @@ -282,6 +282,7 @@ get_fpm_process_count() { # Get memory usage per FPM process for a pool get_fpm_memory_usage() { + [ -z "$1" ] && return 1 local pool_name="$1" # Get average memory per process (in KB) diff --git a/lib/user-manager.sh b/lib/user-manager.sh index 33ebe73..b459729 100755 --- a/lib/user-manager.sh +++ b/lib/user-manager.sh @@ -269,6 +269,7 @@ get_plesk_user_domains() { } get_interworx_user_domains() { + [ -z "$1" ] && return 1 local username="$1" # Method 1: Use listaccounts.pex to get primary domain diff --git a/tools/toolkit-qa-check.sh b/tools/toolkit-qa-check.sh index 7ad52ca..863d2cc 100755 --- a/tools/toolkit-qa-check.sh +++ b/tools/toolkit-qa-check.sh @@ -471,8 +471,11 @@ while read -r file; do # Get function name func_name=$(echo "$func_line" | sed 's/^\s*//; s/(.*$//') - # Check if function uses parameters - if grep -A 20 "^[[:space:]]*$func_name()" "$file" 2>/dev/null | grep -q '\$[1-9]'; then + # Check if function uses parameters (exclude AWK/sed field references) + # Get function body and filter out awk/sed commands before checking for $1-9 + func_body=$(grep -A 20 "^[[:space:]]*$func_name()" "$file" 2>/dev/null | grep -v 'awk\|sed' || true) + + if echo "$func_body" | grep -q '\$[1-9]'; then # Skip if uses safe default pattern: ${1:-default} if grep -A 5 "^[[:space:]]*$func_name()" "$file" 2>/dev/null | grep -qE '\$\{[1-9]:-'; then continue @@ -480,7 +483,6 @@ while read -r file; do # Skip if function doesn't actually use positional params (only uses local vars) # Check first 10 lines of function - if all $1-9 are in local declarations only, skip - func_body=$(grep -A 10 "^[[:space:]]*$func_name()" "$file" 2>/dev/null) if ! echo "$func_body" | grep -v "local.*=" | grep -q '\$[1-9]'; then continue fi