diff --git a/CHANGELOG.md b/CHANGELOG.md index 158ea3c..e626ef4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added ### Changed + - Capture potential `NameError` exception in `asked_for_progress?` method, + related to known JRuby bug (issue #4) ## [0.1.1] ### Added @@ -22,5 +24,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed -[Unreleased]: https://github.com/michenriksen/aquatone/compare/v0.1.0...HEAD +[Unreleased]: https://github.com/michenriksen/aquatone/compare/v0.1.1...HEAD [0.1.1]: https://github.com/michenriksen/aquatone/compare/v0.1.0...v0.1.1 diff --git a/lib/aquatone/command.rb b/lib/aquatone/command.rb index 03bb7f5..a132c10 100644 --- a/lib/aquatone/command.rb +++ b/lib/aquatone/command.rb @@ -112,14 +112,18 @@ def seconds_to_time(seconds) end def asked_for_progress? - while c = STDIN.read_nonblock(1) - return true if c == "\n" + begin + while c = STDIN.read_nonblock(1) + return true if c == "\n" + end + false + rescue IO::EAGAINWaitReadable + false + rescue Errno::EINTR, Errno::EAGAIN, EOFError + true end + rescue NameError false - rescue IO::EAGAINWaitReadable - false - rescue Errno::EINTR, Errno::EAGAIN, EOFError - true end def has_executable?(name)