summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric VERNIER <zerikv@gmail.com>2018-05-21 01:12:10 +0200
committerzerikv <zerikv@gmail.com>2018-07-30 01:10:35 +0200
commit93b8ed9e7b2f13a51dfb7ec01569614e6a171598 (patch)
tree936d73a826808d61badbf8211b2087ea6b42ed97
parent3e3b4c2ac13f3d59dd26042028dfdf1596a26939 (diff)
downloadmixlib-shellout-93b8ed9e7b2f13a51dfb7ec01569614e6a171598.tar.gz
Fix EmptyWindowsCommand error on Windows when the command starts with spaces
Signed-off-by: Eric Vernier <zerikv@gmail.com>
-rw-r--r--lib/mixlib/shellout/windows.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/mixlib/shellout/windows.rb b/lib/mixlib/shellout/windows.rb
index 07d3fbc..75cfd51 100644
--- a/lib/mixlib/shellout/windows.rb
+++ b/lib/mixlib/shellout/windows.rb
@@ -229,12 +229,11 @@ module Mixlib
# FIXME: this extracts ARGV[0] but is it correct?
def candidate_executable_for_command(command)
- if command =~ /^\s*"(.*?)"/
- # If we have quotes, do an exact match
+ if command =~ /^\s*"(.*?)"/ || command =~ /^\s*([^\s]+)/
+ # If we have quotes, do an exact match, else pick the first word ignoring the leading spaces
$1
else
- # Otherwise check everything up to the first space
- command[0, command.index(/\s/) || command.length].strip
+ ""
end
end