Skip to content

Commit 7d6992c

Browse files
committed
respect windows
1 parent d24e294 commit 7d6992c

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

lib/msf/util.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ module Util
2121

2222
# Executable generation and encoding
2323
require 'msf/util/exe'
24+
require 'msf/util/helper'

lib/msf/util/helper.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- coding: binary -*-
2+
3+
module Msf
4+
module Util
5+
class Helper
6+
# Cross-platform way of finding an executable in the $PATH.
7+
#
8+
# which('ruby') #=> /usr/bin/ruby
9+
def self.which(cmd)
10+
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
11+
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
12+
exts.each { |ext|
13+
exe = File.join(path, "#{cmd}#{ext}")
14+
return exe if File.executable?(exe) && !File.directory?(exe)
15+
}
16+
end
17+
return nil
18+
end
19+
end

metasploit-framework.gemspec

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ Gem::Specification.new do |spec|
2525
spec.license = 'BSD-3-clause'
2626

2727
# only do a git ls-files if the .git folder exists and we have a git binary in PATH
28-
if File.directory?(File.join(File.dirname(__FILE__), ".git")) &&
29-
ENV['PATH'].split(':').collect {|d| Dir.entries d if Dir.exists? d}.flatten.include?("git")
28+
if File.directory?(File.join(File.dirname(__FILE__), ".git")) && Msf::Util::Helper.which("git")
3029
spec.files = `git ls-files`.split($/).reject { |file|
3130
file =~ /^documentation|^external/
3231
}

0 commit comments

Comments
 (0)