Skip to content

Commit

Permalink
Switch to array
Browse files Browse the repository at this point in the history
  • Loading branch information
reidsunderland committed Oct 18, 2023
1 parent 5112ea0 commit 281fbba
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions bin/sr3_action_remove
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 281fbba

Please sign in to comment.