summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReid Vandewiele <reid@puppetlabs.com>2015-12-15 21:12:14 -0800
committerReid Vandewiele <reid@puppetlabs.com>2015-12-15 21:17:30 -0800
commit1d838969563d11d30e8efdbb572e071b73d6e028 (patch)
treee85e6658a7dcef59f568deb5d7080402fa51c78a
parent47f55145454c702bfad999ca81e5ffeabd828527 (diff)
downloadsystemu-1d838969563d11d30e8efdbb572e071b73d6e028.tar.gz
Fix problem when ruby exe path has spaces
On Windows, it's possible that the RbConfig path to the ruby executable might contain spaces (e.g. "C:/Program Files/foo/ruby.exe"). If that happens, systemu's previous method of checking to see if that was a valid ruby executable was unreliable. This commit allows full paths to executables to have spaces by switching to individual argument invocation of system(), instead of relying on system() to correctly parse a single string into executable + arguments.
-rw-r--r--lib/systemu.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/systemu.rb b/lib/systemu.rb
index 3812d4e..5f7745a 100644
--- a/lib/systemu.rb
+++ b/lib/systemu.rb
@@ -35,10 +35,10 @@ class SystemUniversal
c = begin; ::RbConfig::CONFIG; rescue NameError; ::Config::CONFIG; end
ruby = File.join(c['bindir'], c['ruby_install_name']) << c['EXEEXT']
- @ruby = if system('%s -e 42' % ruby)
+ @ruby = if system(ruby, '-e', '42')
ruby
else
- system('%s -e 42' % 'ruby') ? 'ruby' : warn('no ruby in PATH/CONFIG')
+ system('ruby', '-e', '42') ? 'ruby' : warn('no ruby in PATH/CONFIG')
end
end