Script doesn't detect terminal when run from pipe
lukas-w opened this issue · 4 comments
The extraction script checks for a terminal using tty -s
which tests whether standard input is connected to a terminal:
Line 568 in e7eb0fd
However, when the script is run from a pipe via e.g. cat installer.run | sh
, this test fails and a new terminal is opened even when already in one. A better way to test this may be [ -t 1 ]
which tests standard output instead.
A possible use-case exposing this bug is running a downloaded script installer such as curl -sS https://example.com/install.sh | sh
.
Thanks for this. As is often the case, I'm always trying to preserve backwards compatibility so I wonder if your [ -t 1 ]
might be a bash-ism. tty
is a standard Unix command that can be reasonably assumed to be available even on legacy systems.
However test -t 1
might be a good enough alternative here.
It does, but our https://example.com/install.sh
is a small wrapper script that downloads the actual .run
installer and then runs it. Maybe this is the reason we're not seeing the error you're getting.