summaryrefslogtreecommitdiff
path: root/lib/mixlib/shellout/windows.rb
diff options
context:
space:
mode:
authorTyler Ball <tball@chef.io>2018-08-20 14:24:56 -0600
committerGitHub <noreply@github.com>2018-08-20 14:24:56 -0600
commite1a267f533e2690698df58dd1c6e72443be489d5 (patch)
tree429fe617e94c13b496b9bf55a32321d9f179403e /lib/mixlib/shellout/windows.rb
parent1d9fe47c38454424403d8507ce842eb6ab19429f (diff)
parent93b8ed9e7b2f13a51dfb7ec01569614e6a171598 (diff)
downloadmixlib-shellout-e1a267f533e2690698df58dd1c6e72443be489d5.tar.gz
Merge pull request #155 from zerikv/fix-win-cmd-lead-space
Avoid EmptyWindowsCommand error on Windows when the command starts with spaces
Diffstat (limited to 'lib/mixlib/shellout/windows.rb')
-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