Skip to content

Commit 3e12c8d

Browse files
committed
Use shell instead of sed.
1 parent 80a7dd4 commit 3e12c8d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

share/chruby/chruby.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ 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+
sortable=()
6+
find "$@" -mindepth 1 -maxdepth 1 -type "d" 2>/dev/null | while read ruby; do
7+
sortable+="${ruby##*/}\t$ruby"
8+
done
9+
sortable=("${sortable[@]/-/.}")
10+
11+
printf "%b\n" "${sortable[@]}" | sort -t "." -k "1,1" -k "2,2n" -k "3,3n" -k "4,4n" | cut -f 2
812
}
913

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

0 commit comments

Comments
 (0)