Check stdin rather than stdout for interactive terminals
What does this merge request do and why?
For GDK::Output.interactive?, we really care about whether the
terminal can take user input. While $stdout.isatty and
$stdin.isatty usually are the same, it's possible that the former
returns true and the latter returns false if input is redirected. For
example, suppose we had a test.rb with the following contents:
puts "stdout TTY? #{$stdout.isatty}"
puts "stdin TTY? #{$stdin.isatty}"
The following shell script would return true and false:
ruby test.rb < test.rb
Impacted categories
The following categories relate to this merge request:
-
gdk-reliability - e.g. When a GDK action fails to complete. -
gdk-usability - e.g. Improvements or suggestions around how the GDK functions. -
gdk-performance - e.g. When a GDK action is slow or times out.
Merge request checklist
-
This change is backward compatible. If not, please include steps to communicate to our users. -
Tests added for new functionality. If not, please raise an issue to follow-up. -
Documentation added/updated, if needed. -
Announcement added, if change is notable. -
gdk doctortest added, if needed. -
Add the ~highlightlabel if this MR should be included in theCHANGELOG.md.
Edited by Stan Hu