module Mina::ExecHelpers
Public Instance Methods
pretty_system(code)
click to toggle source
### pretty_system
Internal: A pretty version of the default `#system` commands, but indents and puts color.
Returns the exit code in integer form.
# File lib/mina-extras/jruby-patch.rb, line 14 def pretty_system(code) require 'shellwords' cmds = Shellwords.shellsplit(code) coathooks = 0 status = Tools.popen4(*cmds) do |pid, i, o, e| # Handle `^C`. trap("INT") { Sys.handle_sigint(coathooks += 1, pid, self) } # __In the background,__ make stdin passthru, and stream stderr. th_err = Sys.stream_stderr!(e) { |str| print_stderr str } th_in = Sys.stream_stdin! { |chr| i.putc chr } # __In the foreground,__ stream stdout to the output helper. Sys.stream_stdout(o) { |ch| print_char ch } th_err.join th_in.terminate end status.exitstatus end