From 281fbbacf9892ae063406f98edd87c0ba50aca14 Mon Sep 17 00:00:00 2001 From: Reid Sunderland Date: Wed, 18 Oct 2023 17:00:35 +0000 Subject: [PATCH] Switch to array --- bin/sr3_action_remove | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/bin/sr3_action_remove b/bin/sr3_action_remove index db7c288..e9246bc 100755 --- a/bin/sr3_action_remove +++ b/bin/sr3_action_remove @@ -16,21 +16,21 @@ sr3_get_git_path_pump_name pump_path="${git_tld}/${pump_name}/" # Get the absolute paths to the files to be removed -files_to_remove="" +files_to_remove=() for argu in "$@"; do if [[ "$argu" == "remove" ]] ; then continue fi - files_to_remove="${files_to_remove} ${pump_path}${argu}.conf" + files_to_remove+=("${pump_path}${argu}.conf") done -if [ -z "${files_to_remove}" ]; then +if [ -z "${files_to_remove}" ] || [ ${#files_to_remove[@]} -eq 0 ]; then echo '[ERROR] no files to remove' exit 2 fi # Files must exist -for file in ${files_to_remove}; do +for file in "${files_to_remove[@]}"; do if [ ! -f "${file}" ]; then echo "[ERROR] File does not exist: ${file}" exit 3 @@ -50,10 +50,11 @@ if ! git pull origin "${MAIN_BRANCH}"; then fi # Remove the files and commit the change -for file in ${files_to_remove}; do +for file in "${files_to_remove[@]}"; do cp -p "${file}" "${file}.off" done -git rm ${files_to_remove} + +git rm "${files_to_remove[@]}" git commit if ! git push origin; then