From 0cad9da2d7bdc79bca17f43f80e346bf6060c389 Mon Sep 17 00:00:00 2001 From: Ada Date: Fri, 15 Nov 2024 15:10:23 -0500 Subject: [PATCH] Add space tolerance and IFS restore --- xseed.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/xseed.sh b/xseed.sh index c7e38bc..b226418 100755 --- a/xseed.sh +++ b/xseed.sh @@ -52,10 +52,22 @@ LOG_FILE=${LOG_FILE:-/config/xseed.log} LOGID_FILE=${LOGID_FILE:-/config/xseed-id.log} XSEED_APIKEY=${XSEED_APIKEY:-} +# Save original IFS +OLD_IFS="$IFS" + # Convert comma-separated strings to arrays IFS=',' read -r -a TORRENT_CLIENT_ARRAY <<< "$TORRENT_CLIENTS" IFS=',' read -r -a USENET_CLIENT_ARRAY <<< "$USENET_CLIENTS" +# Restore original IFS +IFS="$OLD_IFS" + +# Trim whitespace from array elements +TORRENT_CLIENT_ARRAY=("${TORRENT_CLIENT_ARRAY[@]/#[[:space:]]/}") +TORRENT_CLIENT_ARRAY=("${TORRENT_CLIENT_ARRAY[@]/%[[:space:]]/}") +USENET_CLIENT_ARRAY=("${USENET_CLIENT_ARRAY[@]/#[[:space:]]/}") +USENET_CLIENT_ARRAY=("${USENET_CLIENT_ARRAY[@]/%[[:space:]]/}") + log_message "DEBUG" "Using '.env' file for config?: $EVAR" log_message "INFO" "Using configuration:" log_message "INFO" "TORRENT_CLIENTS=$TORRENT_CLIENTS"