From 93b8ed9e7b2f13a51dfb7ec01569614e6a171598 Mon Sep 17 00:00:00 2001 From: Eric VERNIER Date: Mon, 21 May 2018 01:12:10 +0200 Subject: Fix EmptyWindowsCommand error on Windows when the command starts with spaces Signed-off-by: Eric Vernier --- lib/mixlib/shellout/windows.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib/mixlib/shellout') 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 -- cgit v1.2.1