lib/backticks/runner.rb in backticks-1.0.0 vs lib/backticks/runner.rb in backticks-1.0.1
- old
+ new
@@ -1,6 +1,11 @@
-require 'pty'
+begin
+ require 'pty'
+rescue LoadError
+ # for Windows support, tolerate a missing PTY module
+end
+
require 'open3'
module Backticks
# An easy-to-use interface for invoking commands and capturing their output.
# Instances of Runner can be interactive, which prints the command's output
@@ -102,20 +107,24 @@
#
# @param [Array] argv command to run; argv[0] is program name and the
# remaining elements are parameters and flags
# @return [Command] the running command
def run_without_sugar(argv)
- stdin_r, stdin = if buffered.include?(:stdin) && !interactive
+ nopty = !defined?(PTY)
+
+ stdin_r, stdin = if nopty || (buffered.include?(:stdin) && !interactive)
IO.pipe
else
PTY.open
end
- stdout, stdout_w = if buffered.include?(:stdout) && !interactive
+
+ stdout, stdout_w = if nopty || (buffered.include?(:stdout) && !interactive)
IO.pipe
else
PTY.open
end
- stderr, stderr_w = if buffered.include?(:stderr)
+
+ stderr, stderr_w = if nopty || buffered.include?(:stderr)
IO.pipe
else
PTY.open
end