Skip to content

Commit 9e7f0e4

Browse files
committed
Use shell instead of sed.
1 parent 80a7dd4 commit 9e7f0e4

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

share/chruby/chruby.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@ CHRUBY_VERSION="0.3.8"
22

33
function chruby_rubies()
44
{
5-
find "$@" -mindepth 1 -maxdepth 1 -type "d" 2>/dev/null |
6-
sed -e "h" -e 's/.*\///' -e 's/-/./g' -e "G" -e 's/\n/ /' |
7-
sort -t "." -k "1,1" -k "2,2n" -k "3,3n" -k "4,4n" | sed 's/[^ ]* //'
5+
local rubies dir ruby version
6+
rubies=()
7+
for dir in "$@"; do
8+
[[ -d "$dir" && -n $(ls -A "$dir") ]] && for ruby in "$dir"/*; do
9+
version="${ruby##*/}" && rubies+=("${version/-/.}\t$ruby")
10+
done
11+
done
12+
13+
printf "%b\n" "${rubies[@]}" | sort -t "." -k "1,1" -k "2,2n" -k "3,3n" -k "4,4n" | cut -f 2
814
}
915

1016
RUBIES=($(chruby_rubies "$PREFIX/opt/rubies" "$HOME/.rubies"))

test/helper.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ test_ruby_patchlevel="353"
1414
test_ruby_api="2.0.0"
1515
test_ruby_dir="$PWD/test/opt/rubies"
1616
test_ruby_root="$test_ruby_dir/$test_ruby_engine-$test_ruby_version-p$test_ruby_patchlevel"
17-
test_rubies_order="jruby-1.7.9 jruby-1.7.14 rbx-2.2.9 rbx-2.2.10 rbx-10.0.0 ruby-1.9.3-p547 ruby-1.9.3-preview1 ruby-1.9.3-rc1 ruby-2.0.0-p0 ruby-2.0.0-p195 ruby-2.0.0-p247 ruby-2.0.0-p353"
17+
test_rubies_order="jruby-1.7.9 jruby-1.7.10 rbx-2.2.9 rbx-2.2.10 rbx-10.0.0 ruby-1.9.3-p547 ruby-2.0.0-p0 ruby-2.0.0-p195 ruby-2.0.0-p247 ruby-2.0.0-p353 ruby-2.1.0 ruby-2.1.1 ruby-2.1.2"
1818

1919
test_path="$PATH"
2020
test_gem_home="$HOME/.gem/$test_ruby_engine/$test_ruby_version"

test/setup

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ test_ruby_root="$test_ruby_engine-$test_ruby_version-p$test_ruby_patchlevel"
173173
mkdir -p "$PREFIX/opt/rubies"
174174
cd "$PREFIX/opt/rubies"
175175

176-
mkdir -p "jruby-1.7.9" "jruby-1.7.14" "rbx-2.2.9" "rbx-2.2.10" "rbx-10.0.0" \
177-
"ruby-1.9.3-p547" "ruby-1.9.3-preview1" "ruby-1.9.3-rc1" "ruby-2.0.0-p0" \
178-
"ruby-2.0.0-p195" "ruby-2.0.0-p247" "ruby-2.0.0-p353"
176+
mkdir -p "jruby-1.7.9" "jruby-1.7.10" "rbx-2.2.9" "rbx-2.2.10" "rbx-10.0.0" \
177+
"ruby-1.9.3-p547" "ruby-2.0.0-p0" "ruby-2.0.0-p195" "ruby-2.0.0-p247" \
178+
"ruby-2.0.0-p353" "ruby-2.1.0" "ruby-2.1.1" "ruby-2.1.2"
179179

180180
mkdir -p "$PREFIX/opt/r u b i e s/ruby-2.1.2"
181181

0 commit comments

Comments
 (0)