Skip to content

Commit c75800b

Browse files
committed
Skip alias versions by default, add --aliases.
By default, skip ruby versions that are aliases. I'm having a hard time thinking of any reason you would want to run the command on the same ruby version multiple times by default. Also tweak the option parsing and usage messages in support of this change. With versions `2.1 => 2.1.7`, `2.1.6`, and `2.1.7`: $ rbenv each ruby --version ruby 2.1.6p336 (2015-04-13 revision 50298) [x86_64-linux] ruby 2.1.7p400 (2015-08-18 revision 51632) [x86_64-linux] $ rbenv each --aliases ruby --version ruby 2.1.7p400 (2015-08-18 revision 51632) [x86_64-linux] ruby 2.1.6p336 (2015-04-13 revision 50298) [x86_64-linux] ruby 2.1.7p400 (2015-08-18 revision 51632) [x86_64-linux]
1 parent 18466ae commit c75800b

2 files changed

Lines changed: 46 additions & 14 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ the output.
2222
```
2323
$ rbenv each bundle install
2424
$ rbenv each -v rake test
25+
$ rbenv each --skip-aliases bundle check
2526
```

bin/rbenv-each

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,58 @@
22
#
33
# Summary: Execute a command for each Ruby version
44
#
5-
# Usage: rbenv each [-v] <command> [arg1 arg2...]
5+
# Usage: rbenv each [options] <command> [arg1 arg2...]
66
#
7-
# Executes a command for each Ruby version by setting RBENV_VERSION.
7+
# Execute a command for each Ruby version by setting RBENV_VERSION.
88
# Failures are collected and reported at the end.
99
#
10-
# -v Verbose mode. Prints a header for each ruby.
10+
# Options:
11+
# -h, --help Print this help message
12+
# -a, --aliases Don't skip ruby versions that are aliases (symlinks)
13+
# -v, --verbose Verbose mode: print a header for each version version
1114
#
1215
set -e
1316
[ -n "$RBENV_DEBUG" ] && set -x
1417

1518
# Provide rbenv completions
1619
if [ "$1" = "--complete" ]; then
1720
echo -v
21+
echo --verbose
22+
echo -a
23+
echo --aliases
1824
exit
1925
fi
2026

21-
if [ "$1" = "-v" ]; then
22-
verbose=1
23-
shift
24-
fi
27+
usage() {
28+
rbenv-help --usage each >&2
29+
exit 1
30+
}
2531

26-
case "$1" in
27-
"" | -* )
28-
rbenv-help --usage each >&2
29-
exit 1
30-
;;
31-
esac
32+
verbose=
33+
aliases=
34+
35+
while [[ $1 == -* ]]; do
36+
case "$1" in
37+
-v|--verbose)
38+
verbose=1
39+
;;
40+
-a|--aliases)
41+
aliases=1
42+
;;
43+
-h|--help)
44+
rbenv-help each >&2
45+
exit 0
46+
;;
47+
*)
48+
usage
49+
;;
50+
esac
51+
shift
52+
done
53+
54+
if [ $# -lt 1 ]; then
55+
usage
56+
fi
3257

3358
GRAY=""
3459
RED=""
@@ -46,7 +71,13 @@ failed_rubies=""
4671

4772
trap "exit 1" INT
4873

49-
for ruby in $(rbenv versions --bare); do
74+
if [ -n "$aliases" ]; then
75+
opts=
76+
else
77+
opts="--skip-aliases"
78+
fi
79+
80+
for ruby in $(rbenv versions --bare $opts); do
5081
if [ -n "$verbose" ]; then
5182
header="===[$ruby]==================================================================="
5283
header="${header:0:72}"

0 commit comments

Comments
 (0)