Class: TechnoGate::Contao::System
Defined Under Namespace
Classes: ErrorDuringExecution
Class Method Summary collapse
-
.quiet_system(cmd, *args) ⇒ Object
prints no output.
-
.safe_system(cmd, *args) ⇒ Object
Kernel.system but with exceptions.
- .system(cmd, *args) ⇒ Object
Class Method Details
.quiet_system(cmd, *args) ⇒ Object
prints no output
26 27 28 29 30 31 |
# File 'lib/contao/system.rb', line 26 def self.quiet_system cmd, *args self.system(cmd, *args) do $stdout.close $stderr.close end end |
.safe_system(cmd, *args) ⇒ Object
Kernel.system but with exceptions
18 19 20 21 22 23 |
# File 'lib/contao/system.rb', line 18 def self.safe_system cmd, *args unless self.system cmd, *args args = args.map{ |arg| arg.to_s.gsub " ", "\\ " } * " " raise ErrorDuringExecution, "Failure while executing: #{cmd} #{args}" end end |
.system(cmd, *args) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/contao/system.rb', line 6 def self.system cmd, *args fork do yield if block_given? args.collect!{|arg| arg.to_s} exec(cmd, *args) rescue nil exit! 1 # never gets here unless exec failed end Process.wait $?.success? end |