Skip to content

Commit f040e2e

Browse files
committed
gsync: Fix gsync not working with gdrive folder name with space | Fix #126
use eval to to escape the extra qouting
1 parent 9a4ac22 commit f040e2e

File tree

4 files changed

+8
-12
lines changed

4 files changed

+8
-12
lines changed

bash/release/gsync

+2-3
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,7 @@ _check_and_upload() {
571571
[[ -n ${new_files[*]} ]] && printf "" >| "${ERROR_LOG}" && {
572572
declare -A Aseen && for new_file in "${new_files[@]}"; do
573573
{ [[ ${Aseen[new_file]} ]] && continue; } || Aseen[${new_file}]=x
574-
# shellcheck disable=SC2086
575-
if "${COMMAND_NAME}" "${new_file}" ${ARGS}; then
574+
if eval "\"${COMMAND_NAME}\"" "\"${new_file}\"" "${ARGS}"; then
576575
printf "%s\n" "${new_file}" >> "${SUCCESS_LOG}"
577576
else
578577
printf "%s\n" "${new_file}" >> "${ERROR_LOG}"
@@ -748,7 +747,7 @@ _setup_arguments() {
748747
-d | --directory)
749748
_check_longoptions "${1}" "${2}"
750749
GDRIVE_FOLDER="${2}" && shift
751-
ARGS+=" -C ${GDRIVE_FOLDER} "
750+
ARGS+=" -C \"${GDRIVE_FOLDER}\" "
752751
;;
753752
-j | --jobs)
754753
[[ ${2} = v* ]] && SHOW_JOBS_VERBOSE="true" && shift

bash/sync.bash

+2-3
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,7 @@ _check_and_upload() {
218218
[[ -n ${new_files[*]} ]] && printf "" >| "${ERROR_LOG}" && {
219219
declare -A Aseen && for new_file in "${new_files[@]}"; do
220220
{ [[ ${Aseen[new_file]} ]] && continue; } || Aseen[${new_file}]=x
221-
# shellcheck disable=SC2086
222-
if "${COMMAND_NAME}" "${new_file}" ${ARGS}; then
221+
if eval "\"${COMMAND_NAME}\"" "\"${new_file}\"" "${ARGS}"; then
223222
printf "%s\n" "${new_file}" >> "${SUCCESS_LOG}"
224223
else
225224
printf "%s\n" "${new_file}" >> "${ERROR_LOG}"
@@ -395,7 +394,7 @@ _setup_arguments() {
395394
-d | --directory)
396395
_check_longoptions "${1}" "${2}"
397396
GDRIVE_FOLDER="${2}" && shift
398-
ARGS+=" -C ${GDRIVE_FOLDER} "
397+
ARGS+=" -C \"${GDRIVE_FOLDER}\" "
399398
;;
400399
-j | --jobs)
401400
[[ ${2} = v* ]] && SHOW_JOBS_VERBOSE="true" && shift

sh/release/gsync

+2-3
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,7 @@ EOF
564564
*"|:_//_:|${new_file_check_and_upload}|:_//_:|"*) continue ;;
565565
*) aseen_check_and_upload="${aseen_check_and_upload}|:_//_:|${new_file_check_and_upload}|:_//_:|" ;;
566566
esac; do
567-
# shellcheck disable=SC2086
568-
if "${COMMAND_NAME}" "${new_file_check_and_upload}" ${ARGS}; then
567+
if eval "\"${COMMAND_NAME}\"" "\"${new_file_check_and_upload}\"" "${ARGS}"; then
569568
printf "%s\n" "${new_file_check_and_upload}" >> "${SUCCESS_LOG}"
570569
else
571570
printf "%s\n" "${new_file_check_and_upload}" >> "${ERROR_LOG}"
@@ -756,7 +755,7 @@ _setup_arguments() {
756755
-d | --directory)
757756
_check_longoptions "${1}" "${2}"
758757
GDRIVE_FOLDER="${2}" && shift
759-
ARGS=" ${ARGS} -C ${GDRIVE_FOLDER} "
758+
ARGS=" ${ARGS} -C \"${GDRIVE_FOLDER}\" "
760759
;;
761760
-j | --jobs)
762761
case "${2}" in

sh/sync.sh

+2-3
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,7 @@ EOF
233233
*"|:_//_:|${new_file_check_and_upload}|:_//_:|"*) continue ;;
234234
*) aseen_check_and_upload="${aseen_check_and_upload}|:_//_:|${new_file_check_and_upload}|:_//_:|" ;;
235235
esac; do
236-
# shellcheck disable=SC2086
237-
if "${COMMAND_NAME}" "${new_file_check_and_upload}" ${ARGS}; then
236+
if eval "\"${COMMAND_NAME}\"" "\"${new_file_check_and_upload}\"" "${ARGS}"; then
238237
printf "%s\n" "${new_file_check_and_upload}" >> "${SUCCESS_LOG}"
239238
else
240239
printf "%s\n" "${new_file_check_and_upload}" >> "${ERROR_LOG}"
@@ -425,7 +424,7 @@ _setup_arguments() {
425424
-d | --directory)
426425
_check_longoptions "${1}" "${2}"
427426
GDRIVE_FOLDER="${2}" && shift
428-
ARGS=" ${ARGS} -C ${GDRIVE_FOLDER} "
427+
ARGS=" ${ARGS} -C \"${GDRIVE_FOLDER}\" "
429428
;;
430429
-j | --jobs)
431430
case "${2}" in

0 commit comments

Comments
 (0)