Skip to content

Commit 2e2efed

Browse files
committed
remove call to external ls when loading chruby
when the shell does not find files to match a glob expression, the expression is left unchanged. this tests that the expression has been expanded to detect if a directory has files
1 parent a543a35 commit 2e2efed

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

share/chruby/chruby.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ CHRUBY_VERSION="0.3.9"
22
RUBIES=()
33

44
for dir in "$PREFIX/opt/rubies" "$HOME/.rubies"; do
5-
[[ -d "$dir" && -n "$(command ls -A "$dir")" ]] && RUBIES+=("$dir"/*)
5+
[[ -d "$dir" ]] && dir_contents=("$dir"/*) && \
6+
[[ ${#dir_contents[@]} -gt 0 ]] && RUBIES+=(${dir_contents[@]})
67
done
7-
unset dir
8+
unset dir dir_contents
89

910
function chruby_reset()
1011
{

0 commit comments

Comments
 (0)