Skip to content
This repository was archived by the owner on May 16, 2025. It is now read-only.

Commit ae31378

Browse files
committed
Fix not compatible "--" specification problem (BSD versions chmod) | fix labbots#195
1 parent 394d3cf commit ae31378

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

install.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ _variables() {
336336
_download_file() {
337337
cd "${INSTALL_PATH}" 2>| /dev/null 1>&2 || exit 1
338338
# make the file writable if present
339-
[ -f "${INSTALL_PATH}/${COMMAND_NAME}" ] && chmod u+w -- "${INSTALL_PATH}/${COMMAND_NAME}"
339+
[ -f "${INSTALL_PATH}/${COMMAND_NAME}" ] && chmod -- u+w "${INSTALL_PATH}/${COMMAND_NAME}"
340340
_print_center "justify" "${COMMAND_NAME}" "-"
341341
# now download the binary
342342
if script_download_file="$(curl -Ls --compressed "https://github.com/${REPO}/raw/${LATEST_CURRENT_SHA}/release/${INSTALLATION:-}/gupload")"; then
@@ -350,7 +350,7 @@ _download_file() {
350350

351351
[ -n "${SKIP_SYNC}" ] && return 0
352352
# make the file writable if present
353-
[ -f "${INSTALL_PATH}/${SYNC_COMMAND_NAME}" ] && chmod u+w -- "${INSTALL_PATH}/${SYNC_COMMAND_NAME}"
353+
[ -f "${INSTALL_PATH}/${SYNC_COMMAND_NAME}" ] && chmod -- u+w "${INSTALL_PATH}/${SYNC_COMMAND_NAME}"
354354
_print_center "justify" "${SYNC_COMMAND_NAME}" "-"
355355
# now download the binary
356356
if script_download_file="$(curl -Ls --compressed "https://github.com/${REPO}/raw/${LATEST_CURRENT_SHA}/release/${INSTALLATION:-}/gsync")"; then
@@ -418,8 +418,8 @@ _start() {
418418
exit 1
419419
fi
420420

421-
chmod "a-w-r-x,${PERM_MODE:-u}+x+r" -- "${INSTALL_PATH}/${COMMAND_NAME}"
422-
chmod "a-w-r-x,${PERM_MODE:-u}+x+r" -- "${INSTALL_PATH}/${SYNC_COMMAND_NAME}"
421+
chmod -- "a-w-r-x,${PERM_MODE:-u}+x+r" "${INSTALL_PATH}/${COMMAND_NAME}"
422+
chmod -- "a-w-r-x,${PERM_MODE:-u}+x+r" "${INSTALL_PATH}/${SYNC_COMMAND_NAME}"
423423

424424
for _ in 1 2; do _clear_line 1; done
425425

@@ -465,11 +465,11 @@ _start() {
465465
_uninstall() {
466466
_print_center "justify" "Uninstalling.." "-"
467467

468-
chmod -f u+w -- "${INSTALL_PATH}/${COMMAND_NAME}"
468+
chmod -f -- u+w "${INSTALL_PATH}/${COMMAND_NAME}"
469469
rm -f -- "${INSTALL_PATH:?}/${COMMAND_NAME:?}"
470470

471471
[ -z "${SKIP_SYNC}" ] && command -v "${SYNC_COMMAND_NAME}" 2>| /dev/null 1>&2 && {
472-
chmod -f u+w -- "${INSTALL_PATH}/${SYNC_COMMAND_NAME}"
472+
chmod -f -- u+w "${INSTALL_PATH}/${SYNC_COMMAND_NAME}"
473473
rm -f -- "${INSTALL_PATH:?}/${SYNC_COMMAND_NAME:?}"
474474
}
475475

src/common/auth-utils.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ _delete_account() {
106106
if _account_exists "${account_delete_account}"; then
107107
regex_delete_account="^ACCOUNT_${account_delete_account}_(CLIENT_ID=|CLIENT_SECRET=|REFRESH_TOKEN=|ROOT_FOLDER=|ROOT_FOLDER_NAME=|ACCESS_TOKEN=|ACCESS_TOKEN_EXPIRY=)|DEFAULT_ACCOUNT=\"${account_delete_account}\""
108108
config_without_values_delete_account="$(grep -vE "${regex_delete_account}" -- "${CONFIG}")"
109-
chmod u+w -- "${CONFIG}" || return 1 # change perms to edit
109+
chmod -- u+w "${CONFIG}" || return 1 # change perms to edit
110110
printf "%s\n" "${config_without_values_delete_account}" >| "${CONFIG}" || return 1
111-
chmod "a-w-r-x,u+r" -- "${CONFIG}" || return 1 # restore perms
111+
chmod -- "a-w-r-x,u+r" "${CONFIG}" || return 1 # restore perms
112112
"${QUIET:-_print_center}" "normal" " Successfully deleted account ( ${account_delete_account} ) from config. " "-"
113113
else
114114
"${QUIET:-_print_center}" "normal" " Error: Cannot delete account ( ${account_delete_account} ) from config. No such account exists " "-" 1>&2
@@ -132,7 +132,7 @@ _handle_old_config() {
132132
done
133133
regex_check_handle_old_config="^(CLIENT_ID=|CLIENT_SECRET=|REFRESH_TOKEN=|ROOT_FOLDER=|ROOT_FOLDER_NAME=|ACCESS_TOKEN=|ACCESS_TOKEN_EXPIRY=)"
134134
config_without_values_handle_old_config="$(grep -vE "${regex_check_handle_old_config}" -- "${CONFIG}")"
135-
chmod u+w -- "${CONFIG}" || return 1 # change perms to edit
135+
chmod -- u+w "${CONFIG}" || return 1 # change perms to edit
136136
printf "%s\n%s\n%s\n%s\n%s\n%s\n" \
137137
"ACCOUNT_${account_name_handle_old_config}_CLIENT_ID=\"${CLIENT_ID}\"" \
138138
"ACCOUNT_${account_name_handle_old_config}_CLIENT_SECRET=\"${CLIENT_SECRET}\"" \
@@ -141,7 +141,7 @@ _handle_old_config() {
141141
"ACCOUNT_${account_name_handle_old_config}_ROOT_FOLDER_NAME=\"${ROOT_FOLDER_NAME}\"" \
142142
"${config_without_values_handle_old_config}" >| "${CONFIG}" || return 1
143143

144-
chmod "a-w-r-x,u+r" -- "${CONFIG}" || return 1 # restore perms
144+
chmod -- "a-w-r-x,u+r" "${CONFIG}" || return 1 # restore perms
145145

146146
_reload_config || return 1 # reload config file
147147
}

src/common/common-utils.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,9 @@ _update_config() {
407407
[ $# -lt 3 ] && printf "Missing arguments\n" && return 1
408408
value_name_update_config="${1}" value_update_config="${2}" config_path_update_config="${3}"
409409
! [ -f "${config_path_update_config}" ] && : >| "${config_path_update_config}" # If config file doesn't exist.
410-
chmod u+w -- "${config_path_update_config}" || return 1
410+
chmod -- u+w "${config_path_update_config}" || return 1
411411
printf "%s\n%s\n" "$(grep -v -e "^$" -e "^${value_name_update_config}=" -- "${config_path_update_config}" || :)" \
412412
"${value_name_update_config}=\"${value_update_config}\"" >| "${config_path_update_config}" || return 1
413-
chmod a-w-r-x,u+r -- "${config_path_update_config}" || return 1
413+
chmod -- a-w-r-x,u+r "${config_path_update_config}" || return 1
414414
return 0
415415
}

src/common/update.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,6 @@ _update_value() {
6868
printf "%s\n" "Update downloaded but malformed, try again and if the issue persists open an issue on github."
6969
return 1
7070
}
71-
chmod u+w -- "${command_path}" && printf "%s\n" "${new_script}" >| "${command_path}" && chmod "a-w-r-x,${PERM_MODE:-u}+r+x" -- "${command_path}"
71+
chmod -- u+w "${command_path}" && printf "%s\n" "${new_script}" >| "${command_path}" && chmod -- "a-w-r-x,${PERM_MODE:-u}+r+x" "${command_path}"
7272
return 0
7373
}

src/common/upload-common.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ _cleanup_config() {
2424
$(grep -F ACCESS_TOKEN_EXPIRY -- "${config}" || :)
2525
EOF
2626

27-
chmod u+w -- "${config}" &&
27+
chmod -- u+w "${config}" &&
2828
printf "%s\n" "$(grep -Ev "^\$${values_regex:+|${values_regex}}" -- "${config}")" >| "${config}" &&
29-
chmod "a-w-r-x,u+r" -- "${config}"
29+
chmod -- "a-w-r-x,u+r" "${config}"
3030
return 0
3131
}
3232

0 commit comments

Comments
 (0)