Skip to content

Commit 50e91f2

Browse files
committed
Skip alias versions, add --with-aliases option.
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 --with-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 ba46d74 commit 50e91f2

2 files changed

Lines changed: 55 additions & 24 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 --with-aliases bundle check
2526
```

bin/rbenv-each

Lines changed: 54 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,60 @@
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+
#
11+
# Options:
12+
# -h, --help Print this help message
13+
# -a, --with-aliases Don't skip ruby versions that are aliases (symlinks)
14+
# -v, --verbose Verbose mode: print a header for each ruby version
1115
#
1216
set -e
1317
[ -n "$RBENV_DEBUG" ] && set -x
1418

15-
# Provide rbenv completions
16-
case "$1" in
17-
--complete )
18-
echo --help
19-
echo --verbose
20-
exit
21-
;;
22-
-v | --verbose )
23-
verbose=1
24-
shift
25-
;;
26-
--help )
27-
rbenv-help each
28-
exit
29-
;;
30-
"" | -* )
31-
rbenv-help --usage each >&2
32-
exit 1
33-
;;
34-
esac
19+
aliases=
20+
verbose=
21+
22+
while [[ $1 == -* ]]; do
23+
case "$1" in
24+
--)
25+
shift
26+
break
27+
;;
28+
29+
# Provide rbenv completions
30+
--complete )
31+
echo --help
32+
echo --verbose
33+
echo --with-aliases
34+
exit
35+
;;
36+
-a | --with-aliases )
37+
aliases=1
38+
;;
39+
-v | --verbose )
40+
verbose=1
41+
shift
42+
;;
43+
-h | --help )
44+
rbenv-help each
45+
exit
46+
;;
47+
"" | -* )
48+
rbenv-help --usage each >&2
49+
exit 1
50+
;;
51+
esac
52+
shift
53+
done
54+
55+
if [ $# -lt 1 ]; then
56+
rbenv-help --usage each >&2
57+
exit 1
58+
fi
3559

3660
GRAY=""
3761
RED=""
@@ -49,7 +73,13 @@ failed_rubies=""
4973

5074
trap "exit 1" INT
5175

52-
for ruby in $(rbenv versions --bare); do
76+
if [ -n "$aliases" ]; then
77+
opts=
78+
else
79+
opts="--skip-aliases"
80+
fi
81+
82+
for ruby in $(rbenv versions --bare $opts); do
5383
if [ -n "$verbose" ]; then
5484
header="===[$ruby]==================================================================="
5585
header="${header:0:72}"

0 commit comments

Comments
 (0)