From c00943489a2a4f27a35004a6c4854eb9255ddff1 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Sun, 28 Dec 2025 14:58:54 +0800 Subject: [PATCH] Fix bash syntax error caused by newlines in variables (#173) --- lib/clean/user.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/clean/user.sh b/lib/clean/user.sh index f9d6bcf..6800c41 100644 --- a/lib/clean/user.sh +++ b/lib/clean/user.sh @@ -200,7 +200,8 @@ clean_mail_downloads() { # Check directory size threshold local dir_size_kb=0 if command -v du > /dev/null 2>&1; then - dir_size_kb=$(du -sk "$target_path" 2> /dev/null | awk '{print $1}' || echo "0") + dir_size_kb=$(du -sk "$target_path" 2> /dev/null | awk 'NR==1{print $1}') + dir_size_kb=${dir_size_kb:-0} fi # Skip if below threshold @@ -211,7 +212,8 @@ clean_mail_downloads() { # Find and remove files older than specified days while IFS= read -r -d '' file_path; do if [[ -f "$file_path" ]]; then - local file_size_kb=$(du -sk "$file_path" 2> /dev/null | awk '{print $1}' || echo "0") + local file_size_kb=$(du -sk "$file_path" 2> /dev/null | awk 'NR==1{print $1}') + file_size_kb=${file_size_kb:-0} if safe_remove "$file_path" true; then ((count++)) ((cleaned_kb += file_size_kb))