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:
parent
2542f07b08
commit
2a053519aa
2 changed files with 17 additions and 5 deletions
|
@ -5,6 +5,7 @@
|
||||||
* Add 'gem-readme' command, prints the README file bundled with a rubygem
|
* 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
|
* 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 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
|
### 0.10.1
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
# coding: utf-8
|
||||||
class Pry::Terminal
|
class Pry::Terminal
|
||||||
class << self
|
class << self
|
||||||
# Return a pair of [rows, columns] which gives the size of the window.
|
# 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
|
def screen_size_according_to_io_console
|
||||||
return if Pry::Helpers::BaseHelpers.jruby?
|
return if Pry::Helpers::BaseHelpers.jruby?
|
||||||
require 'io/console'
|
|
||||||
$stdout.winsize if $stdout.tty? and $stdout.respond_to?(:winsize)
|
begin
|
||||||
rescue LoadError
|
require 'io/console'
|
||||||
# They probably don't have the io/console stdlib or the io-console gem.
|
|
||||||
# We'll keep trying.
|
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
|
end
|
||||||
|
|
||||||
def screen_size_according_to_env
|
def screen_size_according_to_env
|
||||||
|
|
Loading…
Add table
Reference in a new issue