From 3510686207ecc1eb61e4cda94f9a9d36a3587de7 Mon Sep 17 00:00:00 2001 From: Developer Date: Thu, 19 Mar 2026 22:29:30 -0400 Subject: [PATCH] FIX: Add error handling to remaining piped command assignments Fixed 5 additional piped command assignments that could produce empty values if any command in the pipeline fails with set -eo pipefail: - Line 134: all_domains from grep | cut | tr - Added || echo "" - Line 402: db_prefix from sed | cut - Added || echo "" - Line 689: home_dir from grep | cut - Added || echo "" - Line 729: primary_domain from grep | cut - Added || echo "" - Line 730: home_dir from grep | cut - Added || echo "" - Line 731: disk_used from grep | cut - Added || echo "0" These changes ensure consistent error handling for all piped commands with set -eo pipefail enabled, preventing silent failures and data loss. --- lib/user-manager.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/user-manager.sh b/lib/user-manager.sh index 282b056..beccc99 100755 --- a/lib/user-manager.sh +++ b/lib/user-manager.sh @@ -131,7 +131,7 @@ get_cpanel_user_info() { local home_dir="/home/${username}" # Get addon/parked domains - local all_domains=$(grep "^DNS" -- "$user_file" | cut -d= -f2 | tr '\n' ' ') + local all_domains=$(grep "^DNS" -- "$user_file" | cut -d= -f2 | tr '\n' ' ' || echo "") # Get disk usage local disk_used=$(du -sh "$home_dir" 2>/dev/null | awk '{print $1}' || echo "0B") @@ -399,7 +399,7 @@ get_interworx_user_databases() { fi # Get first 8 characters of domain (removing dots) as database prefix - local db_prefix=$(echo "$primary_domain" | sed 's/\.//g' | cut -c1-8) + local db_prefix=$(echo "$primary_domain" | sed 's/\.//g' | cut -c1-8 || echo "") # Query MySQL for databases with this prefix mysql -e "SHOW DATABASES" 2>/dev/null | grep "^${db_prefix}_" || true @@ -686,7 +686,7 @@ get_database_domain() { find_user_wordpress_sites() { local username="$1" - local home_dir=$(get_user_info "$username" | grep "^HOME_DIR=" | cut -d= -f2) + local home_dir=$(get_user_info "$username" | grep "^HOME_DIR=" | cut -d= -f2 || echo "") if [ -z "$home_dir" ] || [ ! -d "$home_dir" ]; then return 1 @@ -726,9 +726,9 @@ show_user_summary() { fi # Parse info - local primary_domain=$(echo "$user_info" | grep "^PRIMARY_DOMAIN=" | cut -d= -f2) - local home_dir=$(echo "$user_info" | grep "^HOME_DIR=" | cut -d= -f2) - local disk_used=$(echo "$user_info" | grep "^DISK_USED=" | cut -d= -f2) + local primary_domain=$(echo "$user_info" | grep "^PRIMARY_DOMAIN=" | cut -d= -f2 || echo "") + local home_dir=$(echo "$user_info" | grep "^HOME_DIR=" | cut -d= -f2 || echo "") + local disk_used=$(echo "$user_info" | grep "^DISK_USED=" | cut -d= -f2 || echo "0") # Display echo " Username: $username"