Skip to content

Commit c8927ee

Browse files
committed
Expand parse_options to preserve positional arguments after "--"
1 parent 4cec390 commit c8927ee

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

bin/ruby-build

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@ lib() {
2626
parse_options() {
2727
OPTIONS=()
2828
ARGUMENTS=()
29+
EXTRA_ARGUMENTS=()
2930
local arg option index
3031

31-
for arg in "$@"; do
32-
if [ "${arg:0:1}" = "-" ]; then
32+
while [ $# -gt 0 ]; do
33+
arg="$1"
34+
if [ "$arg" == "--" ]; then
35+
shift 1
36+
break
37+
elif [ "${arg:0:1}" = "-" ]; then
3338
if [ "${arg:1:1}" = "-" ]; then
3439
OPTIONS[${#OPTIONS[*]}]="${arg:2}"
3540
else
@@ -40,10 +45,14 @@ lib() {
4045
index=$(($index+1))
4146
done
4247
fi
48+
shift 1
4349
else
4450
ARGUMENTS[${#ARGUMENTS[*]}]="$arg"
51+
shift 1
4552
fi
4653
done
54+
55+
EXTRA_ARGUMENTS=("$@")
4756
}
4857

4958
if [ "$1" == "--$FUNCNAME" ]; then

0 commit comments

Comments
 (0)