Skip to content

Commit 50fc068

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 50fc068

File tree

2 files changed

+52
-24
lines changed

2 files changed

+52
-24
lines changed

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: 51 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,57 @@
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+
while [[ $1 == -* ]]; do
20+
case "$1" in
21+
--)
22+
shift
23+
break
24+
;;
25+
26+
# Provide rbenv completions
27+
--complete )
28+
echo --help
29+
echo --verbose
30+
echo --with-aliases
31+
exit
32+
;;
33+
-a | --with-aliases )
34+
aliases=1
35+
;;
36+
-v | --verbose )
37+
verbose=1
38+
shift
39+
;;
40+
-h | --help )
41+
rbenv-help each
42+
exit
43+
;;
44+
"" | -* )
45+
rbenv-help --usage each >&2
46+
exit 1
47+
;;
48+
esac
49+
shift
50+
done
51+
52+
if [ $# -lt 1 ]; then
53+
rbenv-help --usage each >&2
54+
exit 1
55+
fi
3556

3657
GRAY=""
3758
RED=""
@@ -49,7 +70,13 @@ failed_rubies=""
4970

5071
trap "exit 1" INT
5172

52-
for ruby in $(rbenv versions --bare); do
73+
if [ -n "$aliases" ]; then
74+
opts=
75+
else
76+
opts="--skip-aliases"
77+
fi
78+
79+
for ruby in $(rbenv versions --bare $opts); do
5380
if [ -n "$verbose" ]; then
5481
header="===[$ruby]==================================================================="
5582
header="${header:0:72}"

0 commit comments

Comments
 (0)