Skip to content

Commit

Permalink
Change top-level versions.sh to stop recursing on explicit arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
tianon committed May 21, 2024
1 parent 386636e commit 8d2f482
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions versions.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/usr/bin/env bash
set -Eeuo pipefail

dirs="$(find "$@" -type f -name versions.json -exec bash -Eeuo pipefail -c 'for d; do dir="$(dirname "${d#./}")"; printf " %q" "$dir"; done' -- '{}' +)"
eval "set -- $dirs"
if [ "$#" -eq 0 ]; then
dirs="$(find -type f -name versions.json -exec bash -Eeuo pipefail -c 'for d; do dir="$(dirname "${d#./}")"; printf " %q" "$dir"; done' -- '{}' +)"
eval "set -- $dirs"
fi

if [ "$#" -eq 0 ]; then
echo >&2 "error: failed to find any 'versions.json' files!"
echo >&2 "error: failed to find any 'versions.json' files (in args or '$PWD')!"
exit 1
fi

Expand All @@ -14,7 +16,7 @@ for dir; do

script="$dir"
while [ ! -x "$script/versions.sh" ]; do
if [ "$script" = '.' ]; then
if [ "$script" = '.' ] || [ "$script" = '/' ]; then
echo >&2 "error: failed to find script for '$dir'!"
exit 1
fi
Expand Down

0 comments on commit 8d2f482

Please sign in to comment.