module Rake::AltSystem
Alternate implementations of system() and backticks “ on Windows for ruby-1.8 and earlier.
Constants
- RUNNABLE_EXTS
- RUNNABLE_PATTERN
- WINDOWS
Public Class Methods
Source
# File lib/rake/alt_system.rb 36 def define_module_function(name, &block) 37 define_method(name, &block) 38 module_function(name) 39 end
Public Instance Methods
Source
# File lib/rake/alt_system.rb 98 def backticks(cmd) 99 kernel_backticks(repair_command(cmd)) 100 end
Source
# File lib/rake/alt_system.rb 71 def find_runnable(file) 72 if file =~ RUNNABLE_PATTERN 73 file 74 else 75 RUNNABLE_EXTS.each { |ext| 76 if File.exist?(test = "#{file}.#{ext}") 77 return test 78 end 79 } 80 nil 81 end 82 end
Source
# File lib/rake/alt_system.rb 51 def repair_command(cmd) 52 "call " + ( 53 if cmd =~ %r!\A\s*\".*?\"! 54 # already quoted 55 cmd 56 elsif match = cmd.match(%r!\A\s*(\S+)!) 57 if match[1] =~ %r!/! 58 # avoid x/y.bat interpretation as x with option /y 59 %Q!"#{match[1]}"! + match.post_match 60 else 61 # a shell command will fail if quoted 62 cmd 63 end 64 else 65 # empty or whitespace 66 cmd 67 end 68 ) 69 end
Source
# File lib/rake/alt_system.rb 84 def system(cmd, *args) 85 repaired = ( 86 if args.empty? 87 [repair_command(cmd)] 88 elsif runnable = find_runnable(cmd) 89 [File.expand_path(runnable), *args] 90 else 91 # non-existent file 92 [cmd, *args] 93 end 94 ) 95 kernel_system(*repaired) 96 end