class KTools::Sh
Public Class Methods
ell(cmd)
click to toggle source
Secure mode, asks for confirmation. Shows command. Shows output.
# File lib/ktools/sh.rb, line 6 def self.ell(cmd) puts "Confirmation required." puts "" puts "Command:" puts cmd puts "" print "Y/n: " if "Y" == STDIN.gets.chomp puts "" puts "Running..." puts `#{cmd}` else puts "" puts "Aborted." end end
ell!(cmd)
click to toggle source
Forced mode, won't ask confirmation. Shows command. Shows output.
# File lib/ktools/sh.rb, line 27 def self.ell!(cmd) puts cmd puts `#{cmd}` end
ell_in!(cmd)
click to toggle source
Forced mode, won't ask confirmation. Shows command. Shows output. Loops into the output.
# File lib/ktools/sh.rb, line 51 def self.ell_in!(cmd) puts cmd IO.popen(cmd) do |io| while (line = io.gets) do puts line end end end
ell_meta(cmd)
click to toggle source
Forced mode, won't ask confirmation. It's the meta-shell, or kt-shell mode. It emulates a shell over Ruby's $stdin/$stdout.
# File lib/ktools/sh.rb, line 63 def self.ell_meta(cmd) $stdout.print 'Press enter...' started = false $stdin.each_line do |line| if started pid = fork { exec line } else started = true pid = fork { exec cmd } end Process.wait pid $stdout.print 'kt:shell$ ' end end
ellb!(cmd)
click to toggle source
Forced mode, won't ask confirmation. Won't show command. Shows the output.
# File lib/ktools/sh.rb, line 43 def self.ellb!(cmd) puts `#{cmd}` end
elld!(cmd)
click to toggle source
Forced mode, won't ask confirmation. Won't show command. Won't show output. Returns output.
# File lib/ktools/sh.rb, line 36 def self.elld!(cmd) `#{cmd}` end