Skip to content

Commit

Permalink
Add space tolerance and IFS restore
Browse files Browse the repository at this point in the history
  • Loading branch information
adapowers committed Nov 15, 2024
1 parent ca00d8a commit 0cad9da
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions xseed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 0cad9da

Please sign in to comment.