Added WinRM grep command filter

This is needed because isn't available on Windows and Vagrant guest detection attempts to use grep for some OSs.
This commit is contained in:
Shawn Neal 2014-04-23 20:37:15 -07:00
parent ac81841b01
commit 1525aa0f78
3 changed files with 31 additions and 0 deletions

View File

@ -8,6 +8,7 @@ module VagrantPlugins
"cat",
"chmod",
"chown",
"grep",
"rm",
"test",
"uname",

View File

@ -0,0 +1,26 @@
module VagrantPlugins
module CommunicatorWinRM
module CommandFilters
# Converts a *nix 'grep' command to a PowerShell equivalent
class Grep
def filter(command)
# grep 'Fedora release [12][67890]' /etc/redhat-release
# grep Funtoo /etc/gentoo-release
# grep Gentoo /etc/gentoo-release
# grep is often used to detect the guest type in Vagrant, so don't bother running
# to speed up OS detection
''
end
def accept?(command)
command.start_with?('grep ')
end
end
end
end
end

View File

@ -15,6 +15,10 @@ describe VagrantPlugins::CommunicatorWinRM::CommandFilter, :unit => true do
expect(subject.filter('uname -s stuff')).to eq('')
end
it 'filters out grep commands' do
expect(subject.filter("grep 'Fedora release [12][67890]' /etc/redhat-release")).to eq("")
end
it 'filters out which commands' do
expect(subject.filter('which ruby')).to include(
'[Array](Get-Command ruby -errorAction SilentlyContinue)')