Skip to content

Commit f566a3e

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

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

share/chruby/chruby.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@ 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+
if [[ -d "$dir" && -n $(ls -A "$dir") ]]; then
9+
for ruby in "$dir"/*; do
10+
ruby_basename="${ruby##*/}"
11+
sortable+=("${ruby_basename/-/.}\t$ruby")
12+
done
13+
fi
814
done
9-
sortable=("${sortable[@]/-/.}")
1015

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

0 commit comments

Comments
 (0)