Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

ry exec: default to all installed rubies when none is given #17

Merged
merged 1 commit into from

2 participants

@eregon
Collaborator

Hello,

Still enjoying ry here, and it's finally time to make this a pull request.

Basically, it selects all installed rubies when the first argument is not a ruby name.
If you don't like the behavior, I'd be fine with something like ry exec all some_command.

My Bash skills are very recent, so don't hesitate to heavily improve it.

@eregon
Collaborator

Unfortunately, it did not seem to work with multiple comma separated rubies anymore.
This is due to ${names[0]} returning the whole (now space-separated) $names. Sorry about that.

So I modified and used ${names%%,*} on the unprocessed output and I tested with both bash and zsh.

@eregon
Collaborator

Can I get some feedback on this?

@trans

Maybe a -- should be required between the ry part and the subsequent "some_command" in order ease/ensure parsing?

Also, using all might be better just to be on the safe side. Or am I being cautious over a YAGNI?

@eregon
Collaborator

I'm thinking to use all, as this might not be very clear indeed.

I think explicit -- is not needed, as it should never be necessary (options like "-v" can easily be parsed in ry exec -v <rubies> cmd).

@trans

Sounds good. -- can always be added later if it should ever prove necessary.

@eregon
Collaborator

I amended the commit with all and documentation.
The implementation is now cleaner.

@eregon eregon merged commit a429973 into jneen:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 2 deletions.
  1. +7 −2 bin/ry
View
9 bin/ry
@@ -258,10 +258,15 @@ ry::fullpath() {
#
# ry exec <name>[,<name2>[,...]] <command...>
# execute the given command in the context of the given rub{y,ies}
+# use all installed rubies if <name> is "all"
#
ry::exec() {
local names="$1"; shift
- names="$(tr , "\n" <<<"$names")"
+ if [[ "$names" == "all" ]]; then
+ names="$(ry ls)"
+ else
+ names="$(tr , "\n" <<<"$names")"
+ fi
for name in $names; do
PATH="$(ry fullpath "$name")" "$@"
@@ -316,7 +321,7 @@ ry::usage() {
ry exec <name>[,<name>[,...]] <command...>
Execute <command> in the context of each
- comma-separated ruby.
+ comma-separated ruby (or all installed rubies with "all").
ry binpath <name> Print the bin directory for the given ruby
Something went wrong with that request. Please try again.