From 1e7150f568e4e36d5fd7d3aacfbd3461daad429e Mon Sep 17 00:00:00 2001 From: Andrew Walter Date: Sun, 20 May 2018 00:10:45 +1000 Subject: [PATCH 1/4] Permit `echo` to be used on Windows. --- lib/aruba/platforms/unix_platform.rb | 4 ++++ lib/aruba/platforms/windows_platform.rb | 4 ++++ lib/aruba/processes/spawn_process.rb | 5 ++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/aruba/platforms/unix_platform.rb b/lib/aruba/platforms/unix_platform.rb index 6ce3dc9e1..e01bbfd7e 100644 --- a/lib/aruba/platforms/unix_platform.rb +++ b/lib/aruba/platforms/unix_platform.rb @@ -236,6 +236,10 @@ def simple_table(hash, opts = {}) def which(program, path = ENV['PATH']) UnixWhich.new.call(program, path) end + + def internal_shell_commands + [] + end end end end diff --git a/lib/aruba/platforms/windows_platform.rb b/lib/aruba/platforms/windows_platform.rb index f40fbd3af..8d7edd0ea 100644 --- a/lib/aruba/platforms/windows_platform.rb +++ b/lib/aruba/platforms/windows_platform.rb @@ -37,6 +37,10 @@ def environment_variables def which(program, path = ENV['PATH']) WindowsWhich.new.call(program, path) end + + def internal_shell_commands + ['echo'] + end end end end diff --git a/lib/aruba/processes/spawn_process.rb b/lib/aruba/processes/spawn_process.rb index f85e6f420..c9e993f56 100644 --- a/lib/aruba/processes/spawn_process.rb +++ b/lib/aruba/processes/spawn_process.rb @@ -206,7 +206,7 @@ def terminate end @exit_status = @process.exit_code - + @stdout_cache = read_temporary_output_file @stdout_file @stderr_cache = read_temporary_output_file @stderr_file @@ -262,12 +262,11 @@ def interactive? def command_string fail LaunchError, %(Command "#{command}" not found in PATH-variable "#{environment['PATH']}".) if command_path.nil? - Aruba.platform.command_string.new(command_path, *arguments) end def command_path - @command_path ||= Aruba.platform.which(command, environment['PATH']) + @command_path ||= (Aruba.platform.internal_shell_commands.include?(command) ? command : Aruba.platform.which(command, environment['PATH'])) end def wait_for_io(time_to_wait) From 26db4cccec23aa19ad4ca169d2f44208b7015f95 Mon Sep 17 00:00:00 2001 From: Andrew Walter Date: Thu, 31 May 2018 00:19:55 +1000 Subject: [PATCH 2/4] Renamed `internal_shell_commands` method to `builtin_shell_commands` --- lib/aruba/platforms/unix_platform.rb | 2 +- lib/aruba/platforms/windows_platform.rb | 2 +- lib/aruba/processes/spawn_process.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/aruba/platforms/unix_platform.rb b/lib/aruba/platforms/unix_platform.rb index e01bbfd7e..6cb591c1f 100644 --- a/lib/aruba/platforms/unix_platform.rb +++ b/lib/aruba/platforms/unix_platform.rb @@ -237,7 +237,7 @@ def which(program, path = ENV['PATH']) UnixWhich.new.call(program, path) end - def internal_shell_commands + def builtin_shell_commands [] end end diff --git a/lib/aruba/platforms/windows_platform.rb b/lib/aruba/platforms/windows_platform.rb index 8d7edd0ea..7fa9e08c6 100644 --- a/lib/aruba/platforms/windows_platform.rb +++ b/lib/aruba/platforms/windows_platform.rb @@ -38,7 +38,7 @@ def which(program, path = ENV['PATH']) WindowsWhich.new.call(program, path) end - def internal_shell_commands + def builtin_shell_commands ['echo'] end end diff --git a/lib/aruba/processes/spawn_process.rb b/lib/aruba/processes/spawn_process.rb index c9e993f56..1ff04dc89 100644 --- a/lib/aruba/processes/spawn_process.rb +++ b/lib/aruba/processes/spawn_process.rb @@ -266,7 +266,7 @@ def command_string end def command_path - @command_path ||= (Aruba.platform.internal_shell_commands.include?(command) ? command : Aruba.platform.which(command, environment['PATH'])) + @command_path ||= (Aruba.platform.builtin_shell_commands.include?(command) ? command : Aruba.platform.which(command, environment['PATH'])) end def wait_for_io(time_to_wait) From aa0273950f89478b1e1db4cda880cf61248f14b1 Mon Sep 17 00:00:00 2001 From: Andrew Walter Date: Sun, 10 Jun 2018 18:44:56 +1000 Subject: [PATCH 3/4] Windows: Added support for 'cd'. --- lib/aruba/platforms/windows_platform.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/aruba/platforms/windows_platform.rb b/lib/aruba/platforms/windows_platform.rb index 7fa9e08c6..28191a8d3 100644 --- a/lib/aruba/platforms/windows_platform.rb +++ b/lib/aruba/platforms/windows_platform.rb @@ -39,7 +39,7 @@ def which(program, path = ENV['PATH']) end def builtin_shell_commands - ['echo'] + ['cd', 'echo'] end end end From d99ffb180d1e3537b554a3465cfb602f04223132 Mon Sep 17 00:00:00 2001 From: Andrew Walter Date: Fri, 3 Aug 2018 20:57:13 +1000 Subject: [PATCH 4/4] Windows: Support more built-in commands --- lib/aruba/platforms/windows_platform.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/aruba/platforms/windows_platform.rb b/lib/aruba/platforms/windows_platform.rb index 28191a8d3..268154551 100644 --- a/lib/aruba/platforms/windows_platform.rb +++ b/lib/aruba/platforms/windows_platform.rb @@ -39,7 +39,7 @@ def which(program, path = ENV['PATH']) end def builtin_shell_commands - ['cd', 'echo'] + ['cd', 'dir', 'echo', 'exit', 'set', 'type'] end end end