Closed dmajkic closed 6 years ago
Cool! I've never even tried this on Windows. Are you using MRI or JRuby?
Either way, I'd rather not branch off of the result of a call toGem
. What about using RUBY_PLATFORM
, or, if that's not satisfactory, RbConfig
?
You are right. Branching should be tied to shell, since on Windows there is a number of rubies available (MRI, WSL, jruby, cygwin, msys). This should be a much better fit:
if ENV['SHELL'].nil? && !ENV['COMSPEC'].nil?
$SHELL is defined on Unix and Unix-like enviroments (WSL, cygwin, mysys), and $COMSPEC is defined on Windows. Windows specific code I sent should run only under true Windows command line (powershell, cmd, ...) which always define $COMSPEC. On various environments it looks something like this:
ruby enviroment | $SHELL | $COMSPEC |
---|---|---|
Unix/Linux | /bin/some_sh | nil |
OSX | /bin/some_sh | nil |
Win Cmd MRI | nil | C:/.../cmd.exe |
Win PowerShell MRI | nil | C:/.../cmd.exe |
Win Cmd jRuby | nil | C:/.../cmd.exe |
Win Cygwin | /bin/bash | C:/.../cmd.exe |
Win WSL | /bin/some_sh | nil |
Checking for $SHELL looks enough, but i believe that checking for $COMSPEC should stay too. Let me try all this. Will be back soon.
On Windows platform, Start.exe /B is closest thing to Unix background. And starting cmd /C makes cleaner exit. No extra console windows are shown.