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:

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 doctor test added, if needed.
  • Add the ~highlight label if this MR should be included in the CHANGELOG.md.
Edited by Stan Hu

Merge request reports

Loading