Skip to content

Commit

Permalink
Make array selection bash <4.2 compatible
Browse files Browse the repository at this point in the history
Signed-off-by: Javier Romero <root@jromero.codes>
  • Loading branch information
jromero committed Jul 12, 2022
1 parent f32cc82 commit f9246de
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions scripts/_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function get_tasks() {
tasks=()
for t in $(find ${1} -mindepth 2 -maxdepth 2 -type d); do
parts=(${t//\// })
tasks+=("${parts[-2]}:${parts[-1]}")
tasks+=("${parts[${#parts[@]}-2]}:${parts[${#parts[@]}-1]}")
done
echo "${tasks[@]}"
fi
Expand All @@ -35,7 +35,7 @@ function get_pipelines() {
pipelines=()
for t in $(find ${1} -mindepth 2 -maxdepth 2 -type d); do
parts=(${t//\// })
pipelines+=("${parts[-2]}:${parts[-1]}")
pipelines+=("${parts[${#parts[@]}-2]}:${parts[${#parts[@]}-1]}")
done
echo "${pipelines[@]}"
fi
Expand Down
6 changes: 4 additions & 2 deletions scripts/diff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ DIR="$(dirname "${BASH_SOURCE[0]}")"
source "${DIR}/_common.sh"

# CONFIGURATION

DIFFCMD=$(env_or_default DIFFCMD "git diff --no-index")
DIFFCMD=$(env_or_default DIFFCMD "git diff --no-index --diff-filter=RM")

# DEPENDENCIES

Expand All @@ -31,7 +31,9 @@ function diff_resources() {

new_resource_dir="${resources_dir}/${parts[0]}/${parts[1]}"
echo "> Diffing $type '${parts[0]}/${parts[1]}'..."
echo "---> new: ${new_resource_dir}"
old_resource_dir=$(find "${tmp_dir}/${type}/${parts[0]}" -maxdepth 1 -type d | sort | tail -1)
echo "---> old: ${old_resource_dir}"
$DIFFCMD "${old_resource_dir}" "${new_resource_dir}" || true
echo
echo
Expand Down

0 comments on commit f9246de

Please sign in to comment.