Modified WinRM rm filter to account for -f switch, handle recurse properly
This commit is contained in:
parent
361d41527a
commit
120b15bc39
|
@ -5,14 +5,35 @@ module VagrantPlugins
|
|||
class Rm
|
||||
def filter(command)
|
||||
# rm -Rf /some/dir
|
||||
# rm -R /some/dir
|
||||
# rm -R -f /some/dir
|
||||
# rm -f /some/dir
|
||||
# rm /some/dir
|
||||
cmd_parts = command.strip.split(/\s+/)
|
||||
dir = cmd_parts[1]
|
||||
if dir == '-Rf'
|
||||
dir = cmd_parts[2]
|
||||
return "rm '#{dir}' -recurse -force"
|
||||
|
||||
# Figure out if we need to do this recursively
|
||||
recurse = false
|
||||
cmd_parts.each do |k|
|
||||
argument = k.downcase
|
||||
if argument == '-r' || argument == '-rf' || argument == '-fr'
|
||||
recurse = true
|
||||
break
|
||||
end
|
||||
end
|
||||
return "rm '#{dir}' -force"
|
||||
|
||||
# Figure out which argument is the path
|
||||
dir = cmd_parts.pop
|
||||
while !dir.nil? && dir.start_with?('-')
|
||||
dir = cmd_parts.pop
|
||||
end
|
||||
|
||||
ret_cmd = ''
|
||||
if recurse
|
||||
ret_cmd = "rm #{dir} -recurse -force"
|
||||
else
|
||||
ret_cmd = "rm #{dir} -force"
|
||||
end
|
||||
return ret_cmd
|
||||
end
|
||||
|
||||
def accept?(command)
|
||||
|
|
Loading…
Reference in New Issue