Skip to content
This repository has been archived by the owner on Mar 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request rust-lang#334 from japaric/no-tty
Browse files Browse the repository at this point in the history
rustup-setup: don't open /dev/tty if '-y' is passed
  • Loading branch information
brson committed Apr 17, 2016
2 parents 722d135 + b0f3116 commit 54ce20f
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions rustup-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,33 @@ main() {
ensure curl -sSfL "$_url" -o "$_file"
ensure chmod u+x "$_file"

# The installer is going to want to ask for confirmation by
# reading stdin. This script was piped into `sh` though and
# doesn't have stdin to pass to its children. Instead we're going
# to explicitly connect /dev/tty to the installer's stdin.
if [ ! -e "/dev/tty" ]; then
err "/dev/tty does not exist"
fi
# check if we have to use /dev/tty to prompt the user
local need_tty=yes
for arg in "$@"; do
case "$arg" in
-y)
# user wants to skip the prompt -- we don't need /dev/tty
need_tty=no
;;
*)
;;
esac
done


if [ "$need_tty" = "yes" ]; then
# The installer is going to want to ask for confirmation by
# reading stdin. This script was piped into `sh` though and
# doesn't have stdin to pass to its children. Instead we're going
# to explicitly connect /dev/tty to the installer's stdin.
if [ ! -e "/dev/tty" ]; then
err "/dev/tty does not exist"
fi

run "$_file" "$@" < /dev/tty
run "$_file" "$@" < /dev/tty
else
run "$_file" "$@"
fi

local _retval=$?

Expand Down

0 comments on commit 54ce20f

Please sign in to comment.