Skip to content

Instantly share code, notes, and snippets.

@chriseppstein
Created October 12, 2011 15:49
Show Gist options
  • Save chriseppstein/1281586 to your computer and use it in GitHub Desktop.
Save chriseppstein/1281586 to your computer and use it in GitHub Desktop.
Execute the same command in each installed ruby via rbenv
#!/bin/bash
verbose=0
function usage() {
echo >&2 "Usage: rbenv each [-v] ..."
echo >&2 " -v Verbose mode. Prints a header for each ruby."
}
while getopts vh option
do case "$option" in
v) verbose=1;;
h) usage; exit 0;;
[?])
usage;
exit 1;;
esac
done
shift $(($OPTIND-1))
failed_rubies=""
for ruby in `rbenv versions --bare`; do
if [ $verbose = 1 ]; then
echo -e "\033[1;34m[$ruby]:\033[0m \033[1;32m$@\033[0m";
echo -e "\033[1;34m******************************************************************\033[0m";
fi
RBENV_VERSION=$ruby $@
if [ $verbose = 1 ]; then
echo
fi
if [ $? != 0 ]; then
failed_rubies="$failed_rubies $ruby"
fi
done
if [ -n "$failed_rubies" ]; then
echo -e "\033[1;31mFAILED IN:$failed_rubies\033[0m"
fi
$ rbenv each bundle install
$ rbenv each -v rake test
@chriseppstein
Copy link
Author

See: https://github.com/chriseppstein/rbenv-each to install as a plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment