35: def define_module_function(name, &block)
36: define_method(name, &block)
37: module_function(name)
38: end
97: def backticks(cmd)
98: kernel_backticks(repair_command(cmd))
99: end
70: def find_runnable(file)
71: if file =~ RUNNABLE_PATTERN
72: file
73: else
74: RUNNABLE_EXTS.each { |ext|
75: if File.exist?(test = "#{file}.#{ext}")
76: return test
77: end
78: }
79: nil
80: end
81: end
50: def repair_command(cmd)
51: "call " + (
52: if cmd =~ %r!\A\s*\".*?\"!
53:
54: cmd
55: elsif match = cmd.match(%r!\A\s*(\S+)!)
56: if match[1] =~ %r!/!
57:
58: %Q!"#{match[1]}"! + match.post_match
59: else
60:
61: cmd
62: end
63: else
64:
65: cmd
66: end
67: )
68: end
83: def system(cmd, *args)
84: repaired = (
85: if args.empty?
86: [repair_command(cmd)]
87: elsif runnable = find_runnable(cmd)
88: [File.expand_path(runnable), *args]
89: else
90:
91: [cmd, *args]
92: end
93: )
94: kernel_system(*repaired)
95: end