Skip to content

Commit 08a317f

Browse files
authored
Merge pull request #2815 from umanwizard/fix_short_opts
Detect '-y' short option in rustup-init.sh more robustly
2 parents 6acf004 + 1089a58 commit 08a317f

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

rustup-init.sh

+22-5
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,32 @@ main() {
9090
local need_tty=yes
9191
for arg in "$@"; do
9292
case "$arg" in
93-
-h|--help)
93+
--help)
9494
usage
9595
exit 0
9696
;;
97-
-y)
98-
# user wants to skip the prompt -- we don't need /dev/tty
99-
need_tty=no
100-
;;
10197
*)
98+
OPTIND=1
99+
if [ "${arg%%--*}" = "" ]; then
100+
# Long option (other than --help);
101+
# don't attempt to interpret it.
102+
continue
103+
fi
104+
while getopts :hy sub_arg "$arg"; do
105+
case "$sub_arg" in
106+
h)
107+
usage
108+
exit 0
109+
;;
110+
y)
111+
# user wants to skip the prompt --
112+
# we don't need /dev/tty
113+
need_tty=no
114+
;;
115+
*)
116+
;;
117+
esac
118+
done
102119
;;
103120
esac
104121
done

0 commit comments

Comments
 (0)