From 8d2f4827205e8eb15458165bbc98d0cea35188d2 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Tue, 21 May 2024 16:50:32 -0700 Subject: [PATCH] Change top-level `versions.sh` to stop recursing on explicit arguments --- versions.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/versions.sh b/versions.sh index 76e16c46bf74..154cabb3f6d8 100755 --- a/versions.sh +++ b/versions.sh @@ -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 @@ -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