Skip to content

Commit fd4d277

Browse files
committed
fix: Expand positional arguments after all options have been processed
1 parent a82ae92 commit fd4d277

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

bashunit

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ source "$BASHUNIT_ROOT_DIR/src/main.sh"
3232

3333
_ASSERT_FN=""
3434
_FILTER=""
35+
_RAW_ARGS=()
3536
_ARGS=()
3637
_BENCH_MODE=false
3738

@@ -105,16 +106,23 @@ while [[ $# -gt 0 ]]; do
105106
trap '' EXIT && exit 0
106107
;;
107108
*)
108-
pattern='*[tT]est.sh'
109-
[[ "$_BENCH_MODE" == true ]] && pattern='*[bB]ench.sh'
110-
while IFS= read -r file; do
111-
_ARGS+=("$file")
112-
done < <(helper::find_files_recursive "$1" "$pattern")
109+
_RAW_ARGS+=("$1")
113110
;;
114111
esac
115112
shift
116113
done
117114

115+
# Expand positional arguments after all options have been processed
116+
if [[ ${#_RAW_ARGS[@]} -gt 0 ]]; then
117+
pattern='*[tT]est.sh'
118+
[[ "$_BENCH_MODE" == true ]] && pattern='*[bB]ench.sh'
119+
for arg in "${_RAW_ARGS[@]}"; do
120+
while IFS= read -r file; do
121+
_ARGS+=("$file")
122+
done < <(helper::find_files_recursive "$arg" "$pattern")
123+
done
124+
fi
125+
118126
# Optional bootstrap
119127
# shellcheck disable=SC1090
120128
[[ -f "${BASHUNIT_BOOTSTRAP:-}" ]] && source "$BASHUNIT_BOOTSTRAP"

0 commit comments

Comments
 (0)