From 03e4d95f2d8db7598b3e8220a3301021e8cdeb48 Mon Sep 17 00:00:00 2001 From: Yaro Kasear Date: Wed, 16 Apr 2025 15:30:57 -0500 Subject: [PATCH] Add debug output for email attachments in runtest.sh for better traceability --- runtest.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/runtest.sh b/runtest.sh index 6a0f499..b111ede 100755 --- a/runtest.sh +++ b/runtest.sh @@ -1,5 +1,9 @@ #!/bin/bash +set -x +set -euo pipefail +IFS=$'\n\t' + source settings.env # Check if email recipient is set @@ -150,7 +154,18 @@ fi if [ ${#ATTACHMENTS[@]} -eq 0 ]; then echo "[!] No files to attach. Email not sent." else - echo "$EMAIL_BODY" | mutt -s "$EMAIL_SUBJECT" "${ATTACHMENTS[@]/#/ -a}" -- "$RECIPIENT" + # Print attachments for debugging + for file in "${ATTACHMENTS[@]}"; do + echo "[DEBUG] Attaching: '$file'" + done + + # Safely quote and attach + ATTACHMENT_FLAGS=() + for file in "${ATTACHMENTS[@]}"; do + ATTACHMENT_FLAGS+=("-a" "$file") + done + + echo "$EMAIL_BODY" | mutt -s "$EMAIL_SUBJECT" "${ATTACHMENT_FLAGS[@]}" -- "$RECIPIENT" fi echo "[+] Email sent to $RECIPIENT with attachments: ${ATTACHMENTS[*]}"