From f040e2edb08370442837216fef313e51d7a1d450 Mon Sep 17 00:00:00 2001 From: Akianonymus Date: Thu, 5 Nov 2020 08:16:42 +0530 Subject: [PATCH] gsync: Fix gsync not working with gdrive folder name with space | Fix #126 use eval to to escape the extra qouting --- bash/release/gsync | 5 ++--- bash/sync.bash | 5 ++--- sh/release/gsync | 5 ++--- sh/sync.sh | 5 ++--- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/bash/release/gsync b/bash/release/gsync index 70a5a4e..0125edd 100755 --- a/bash/release/gsync +++ b/bash/release/gsync @@ -571,8 +571,7 @@ _check_and_upload() { [[ -n ${new_files[*]} ]] && printf "" >| "${ERROR_LOG}" && { declare -A Aseen && for new_file in "${new_files[@]}"; do { [[ ${Aseen[new_file]} ]] && continue; } || Aseen[${new_file}]=x - # shellcheck disable=SC2086 - if "${COMMAND_NAME}" "${new_file}" ${ARGS}; then + if eval "\"${COMMAND_NAME}\"" "\"${new_file}\"" "${ARGS}"; then printf "%s\n" "${new_file}" >> "${SUCCESS_LOG}" else printf "%s\n" "${new_file}" >> "${ERROR_LOG}" @@ -748,7 +747,7 @@ _setup_arguments() { -d | --directory) _check_longoptions "${1}" "${2}" GDRIVE_FOLDER="${2}" && shift - ARGS+=" -C ${GDRIVE_FOLDER} " + ARGS+=" -C \"${GDRIVE_FOLDER}\" " ;; -j | --jobs) [[ ${2} = v* ]] && SHOW_JOBS_VERBOSE="true" && shift diff --git a/bash/sync.bash b/bash/sync.bash index 30188f1..ce5c5de 100755 --- a/bash/sync.bash +++ b/bash/sync.bash @@ -218,8 +218,7 @@ _check_and_upload() { [[ -n ${new_files[*]} ]] && printf "" >| "${ERROR_LOG}" && { declare -A Aseen && for new_file in "${new_files[@]}"; do { [[ ${Aseen[new_file]} ]] && continue; } || Aseen[${new_file}]=x - # shellcheck disable=SC2086 - if "${COMMAND_NAME}" "${new_file}" ${ARGS}; then + if eval "\"${COMMAND_NAME}\"" "\"${new_file}\"" "${ARGS}"; then printf "%s\n" "${new_file}" >> "${SUCCESS_LOG}" else printf "%s\n" "${new_file}" >> "${ERROR_LOG}" @@ -395,7 +394,7 @@ _setup_arguments() { -d | --directory) _check_longoptions "${1}" "${2}" GDRIVE_FOLDER="${2}" && shift - ARGS+=" -C ${GDRIVE_FOLDER} " + ARGS+=" -C \"${GDRIVE_FOLDER}\" " ;; -j | --jobs) [[ ${2} = v* ]] && SHOW_JOBS_VERBOSE="true" && shift diff --git a/sh/release/gsync b/sh/release/gsync index e0bb101..8c7cc4e 100755 --- a/sh/release/gsync +++ b/sh/release/gsync @@ -564,8 +564,7 @@ EOF *"|:_//_:|${new_file_check_and_upload}|:_//_:|"*) continue ;; *) aseen_check_and_upload="${aseen_check_and_upload}|:_//_:|${new_file_check_and_upload}|:_//_:|" ;; esac; do - # shellcheck disable=SC2086 - if "${COMMAND_NAME}" "${new_file_check_and_upload}" ${ARGS}; then + if eval "\"${COMMAND_NAME}\"" "\"${new_file_check_and_upload}\"" "${ARGS}"; then printf "%s\n" "${new_file_check_and_upload}" >> "${SUCCESS_LOG}" else printf "%s\n" "${new_file_check_and_upload}" >> "${ERROR_LOG}" @@ -756,7 +755,7 @@ _setup_arguments() { -d | --directory) _check_longoptions "${1}" "${2}" GDRIVE_FOLDER="${2}" && shift - ARGS=" ${ARGS} -C ${GDRIVE_FOLDER} " + ARGS=" ${ARGS} -C \"${GDRIVE_FOLDER}\" " ;; -j | --jobs) case "${2}" in diff --git a/sh/sync.sh b/sh/sync.sh index 4720d2b..26ee6dc 100755 --- a/sh/sync.sh +++ b/sh/sync.sh @@ -233,8 +233,7 @@ EOF *"|:_//_:|${new_file_check_and_upload}|:_//_:|"*) continue ;; *) aseen_check_and_upload="${aseen_check_and_upload}|:_//_:|${new_file_check_and_upload}|:_//_:|" ;; esac; do - # shellcheck disable=SC2086 - if "${COMMAND_NAME}" "${new_file_check_and_upload}" ${ARGS}; then + if eval "\"${COMMAND_NAME}\"" "\"${new_file_check_and_upload}\"" "${ARGS}"; then printf "%s\n" "${new_file_check_and_upload}" >> "${SUCCESS_LOG}" else printf "%s\n" "${new_file_check_and_upload}" >> "${ERROR_LOG}" @@ -425,7 +424,7 @@ _setup_arguments() { -d | --directory) _check_longoptions "${1}" "${2}" GDRIVE_FOLDER="${2}" && shift - ARGS=" ${ARGS} -C ${GDRIVE_FOLDER} " + ARGS=" ${ARGS} -C \"${GDRIVE_FOLDER}\" " ;; -j | --jobs) case "${2}" in