1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

terminal: rescue Errno::EOPNOTSUPP

Fixes #1352 (crash when $stdout is a socket)

Spin defines its own `#tty?` method on `$stdout`, which breaks Pry.

9112a702a1/lib/spin.rb (L342)
This commit is contained in:
Kyrylo Silin 2015-02-26 15:33:45 +02:00
parent 2542f07b08
commit 2a053519aa
2 changed files with 17 additions and 5 deletions

View file

@ -5,6 +5,7 @@
* Add 'gem-readme' command, prints the README file bundled with a rubygem
* Add 'gem-search' command, searches for a gem with the rubygems.org HTTP API
* Fixed bug in the `cat` command where it was impossible to use line numbers with files ([#1349](https://github.com/pry/pry/issues/1349))
* Fixed uncaught Errno::EOPNOTSUPP exception when $stdout is a socket ([#1352](https://github.com/pry/pry/issues/1352))
### 0.10.1

View file

@ -1,3 +1,4 @@
# coding: utf-8
class Pry::Terminal
class << self
# Return a pair of [rows, columns] which gives the size of the window.
@ -41,11 +42,21 @@ class Pry::Terminal
def screen_size_according_to_io_console
return if Pry::Helpers::BaseHelpers.jruby?
require 'io/console'
$stdout.winsize if $stdout.tty? and $stdout.respond_to?(:winsize)
rescue LoadError
# They probably don't have the io/console stdlib or the io-console gem.
# We'll keep trying.
begin
require 'io/console'
begin
if $stdout.tty? && $stdout.respond_to?(:winsize)
$stdout.winsize
end
rescue Errno::EOPNOTSUPP
# $stdout is probably a socket, which doesn't support #winsize.
end
rescue LoadError
# They probably don't have the io/console stdlib or the io-console gem.
# We'll keep trying.
end
end
def screen_size_according_to_env