Sha256: 1e51ee23750ea52b9b929d5f8d91857ba52559c823537af8b5fce61be5436989

Contents?: true

Size: 601 Bytes

Versions: 2

Compression:

Stored size: 601 Bytes

Contents

module VagrantWindows
  module Communication
    module CommandFilters

      # Converts a *nix 'which' command to a PowerShell equivalent
      class Which

        def filter(command)
          executable = command.strip.split(/\s+/)[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

2 entries across 2 versions & 1 rubygems

Version Path
vagrant-windows-1.7.0.pre.2 lib/vagrant-windows/communication/command_filters/which.rb
vagrant-windows-1.7.0.pre.1 lib/vagrant-windows/communication/command_filters/which.rb