Skip to content

Commit

Permalink
remove some obsolete methods
Browse files Browse the repository at this point in the history
  • Loading branch information
quix committed Dec 15, 2008
1 parent 00a0493 commit 2b0e1a8
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions repaired_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@
# Alternate implementations of system() and backticks `` for Windows.
#
module RepairedSystem
COMSPEC = ENV["ComSpec"]

BINARY_EXTS = %w[com exe]

BATCHFILE_EXTS = %w[bat] +
if (t = ENV["COMSPEC"]) and t =~ %r!command\.exe\Z!i
[]
else
if File.basename(COMSPEC) =~ %r!cmd!i
%w[cmd]
else
[]
end

RUNNABLE_EXTS = BINARY_EXTS + BATCHFILE_EXTS
Expand Down Expand Up @@ -75,16 +77,6 @@ def repair_command(cmd)
end
end

def join_command(*args)
first =
if args.first =~ %r!\s!
quote(args.first)
else
args.first
end
[to_backslashes(first), *tail(args)].join(" ")
end

def to_backslashes(string)
string.gsub("/", "\\")
end
Expand All @@ -93,10 +85,6 @@ def quote(string)
%Q!"#{string}"!
end

def tail(array)
array[1..-1]
end

def find_runnable(file)
if file =~ RUNNABLE_PATTERN
file
Expand All @@ -116,11 +104,11 @@ def system(cmd, *args)
if args.empty?
[repair_command(file)]
elsif file =~ BATCHFILE_PATTERN
[ENV["ComSpec"], "/c", to_backslashes(File.expand_path(file)), *args]
[COMSPEC, "/c", to_backslashes(File.expand_path(file)), *args]
elsif runnable = find_runnable(file)
[to_backslashes(File.expand_path(runnable)), *args]
else
# your friends can't save you now
# shell command or non-existent non-batchfile
args
end
system_previous(*repaired_args)
Expand Down

0 comments on commit 2b0e1a8

Please sign in to comment.