Sha256: 481a8bb287d9a31c1ff6090d4bd8ca31bfd2d5e6f3438ade76b7aa3403392556

Contents?: true

Size: 630 Bytes

Versions: 31

Compression:

Stored size: 630 Bytes

Contents

require "shellwords"

module VagrantPlugins
  module CommunicatorWinRM
    module CommandFilters
      # Converts a *nix 'which' command to a PowerShell equivalent
      class Which
        def filter(command)
          executable = Shellwords.split(command.strip)[1]
          return <<-EOH
            $command = [Array](Get-Command "#{executable}" -errorAction SilentlyContinue)
            if ($null -eq $command) { exit 1 }
            write-host $command[0].Definition
            exit 0
          EOH
        end

        def accept?(command)
          command.start_with?('which ')
        end
      end
    end
  end
end

Version data entries

31 entries across 27 versions & 4 rubygems

Version Path
vagrant-unbundled-2.2.0.0 plugins/communicators/winrm/command_filters/which.rb
vagrant-unbundled-2.1.4.0 plugins/communicators/winrm/command_filters/which.rb
vagrant-unbundled-2.1.2.0 plugins/communicators/winrm/command_filters/which.rb
vagrant-packet-0.1.2 vendor/bundle/ruby/2.5.0/bundler/gems/vagrant-04f7215b5e3f/plugins/communicators/winrm/command_filters/which.rb
vagrant-packet-0.1.2 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-04f7215b5e3f/plugins/communicators/winrm/command_filters/which.rb
vagrant-packet-0.1.2 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-04f7215b5e3f/plugins/communicators/winrm/command_filters/which.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-04f7215b5e3f/plugins/communicators/winrm/command_filters/which.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/bundler/gems/vagrant-04f7215b5e3f/plugins/communicators/winrm/command_filters/which.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-04f7215b5e3f/plugins/communicators/winrm/command_filters/which.rb
vagrant-unbundled-2.1.1.0 plugins/communicators/winrm/command_filters/which.rb
vagrant-unbundled-2.0.4.0 plugins/communicators/winrm/command_filters/which.rb