Skip to content

Commit d0a6f1d

Browse files
committed
Use shell instead of find.
1 parent 3e12c8d commit d0a6f1d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

share/chruby/chruby.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ CHRUBY_VERSION="0.3.8"
33
function chruby_rubies()
44
{
55
sortable=()
6-
find "$@" -mindepth 1 -maxdepth 1 -type "d" 2>/dev/null | while read ruby; do
7-
sortable+="${ruby##*/}\t$ruby"
6+
7+
for dir in "$@"; do
8+
[[ -d "$dir" && -n $(ls -A "$dir") ]] && for ruby in "$dir"/*; do
9+
ruby_basename="${ruby##*/}" && sortable+=("${ruby_basename/-/.}\t$ruby")
10+
done
811
done
9-
sortable=("${sortable[@]/-/.}")
1012

1113
printf "%b\n" "${sortable[@]}" | sort -t "." -k "1,1" -k "2,2n" -k "3,3n" -k "4,4n" | cut -f 2
1214
}

0 commit comments

Comments
 (0)