Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
chruby-exec seems to be broken #10
I am running OSX 10.9.3, along with the following:
~ $ chruby --version chruby: 0.3.8 chruby-fish: 0.6.0 ~ $ fish --version fish, version 2.1.0 ~ $
However, when trying to execute
~ $ chruby jruby-1.7.12 * ruby-2.1.2 ~ $ chruby-exec jruby-1.7.12 -- gem env fish: Expected a command name, got token of type 'Run job in background'. Did you mean 'COMMAND; and COMMAND'? See the help section for the 'and' builtin command by typing 'help and'. Standard input: chruby jruby-1.7.12 && gem env ^ ~ $
The error you get is because you are executing the bash version of
I had a stab at implementing this today, but ran into a problem.
The way the bash version of chruby-exec works is by passing a properly escaped (shellquoted) string to
Without proper escaping, the only way to make
The best solution would be to use a custom escape function for fish. I haven't been able to find one and don't trust my fish skills enough to write one. Bash'
Here's the script and (failing) test-file that requires the manual escaping.
#!/usr/bin/env fish source (dirname (status -f))/../share/chruby/chruby.fish switch $argv; case "-h" "--help" echo "usage: chruby-exec RUBY [RUBYOPTS] -- COMMAND [ARGS...]" exit case "-V" "--version" echo "chruby version " $CHRUBY_VERSION echo "chruby-fish version " $CHRUBY_FISH_VERSION exit end if test (count $argv) -eq 0; echo "chruby-exec: RUBY and COMMAND required" exit 1 end for arg in $argv; set -e argv set chruby_args $chruby_args $arg if test "$arg" = "--"; set -e chruby_args[-1] break end end if test (count $argv) -eq 0; echo "chruby-exec: COMMAND required" exit 1 end # TODO: Properly escape $argv here set cmd "\"chruby $chruby_args; and $argv\"" if isatty 0; eval exec "$SHELL -i -l -c $cmd" else eval exec "$SHELL -c $cmd" end
function suite_chruby_exec function setup set PATH (dirname (status -f))../bin $PATH set RUBIES (dirname (status -f))/opt/rubies end function test_chruby_exec_no_arguments bin/chruby-exec 2>/dev/null assert_equal $status 1 end function test_chruby_exec_no_command bin/chruby-exec "$test_ruby_version" 2>/dev/null assert_equal $status 1 end function test_chruby_exec set -l ruby_version (eval "bin/chruby-exec $test_ruby_version -- ruby -e \"print RUBY_VERSION\"") echo $ruby_version assert_equal "$test_ruby_version" "$ruby_version" end end if not set -q tank_running . (dirname (status -f))/helper.fish tank_run reset_system_defaults end