Method: Rake::AltSystem.repair_command

Defined in:
lib/rake/alt_system.rb

.repair_command(cmd) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/rake/alt_system.rb', line 53

def repair_command(cmd)
  "call " + (
    if cmd =~ %r!\A\s*\".*?\"!
      # already quoted
      cmd
    elsif match = cmd.match(%r!\A\s*(\S+)!)
      if match[1] =~ %r!/!
        # avoid x/y.bat interpretation as x with option /y
        %Q!"#{match[1]}"! + match.post_match
      else
        # a shell command will fail if quoted
        cmd
      end
    else
      # empty or whitespace
      cmd
    end
  )
end