From 04bf9aff3987c8f2543ff887cbb9f4bc6737e871 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 3 Sep 2017 20:00:54 +0200 Subject: [PATCH] Bugfix: empty rsync_options line causes destroying source. (#8) Bugfix: empty rsync_options line causes destroying source. --- ccollect | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ccollect b/ccollect index 47526ad..edae187 100755 --- a/ccollect +++ b/ccollect @@ -655,7 +655,17 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # if [ -f "${c_rsync_options}" ]; then while read line; do - set -- "$@" "${line}" + # Trim line. + ln=$(echo "${line}" | awk '{$1=$1;print;}') + # Only if ln is non zero length string. + # + # If ln is empty then rsync '' DEST evaluates + # to transfer current directory to DEST which would + # with specific options destroy DEST content. + if [ -n "${ln}" ] + then + set -- "$@" "${ln}" + fi done < "${c_rsync_options}" fi