Skip to content

Commit

Permalink
gsync: Fix gsync not working with gdrive folder name with space | Fix #…
Browse files Browse the repository at this point in the history
…126

use eval to to escape the extra qouting
  • Loading branch information
Akianonymus committed Nov 7, 2020
1 parent 9a4ac22 commit f040e2e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
5 changes: 2 additions & 3 deletions bash/release/gsync
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions bash/sync.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions sh/release/gsync
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions sh/sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f040e2e

Please sign in to comment.