From 2e2efedb1a4345e6e10117f6fd694880f700b958 Mon Sep 17 00:00:00 2001 From: Keenan Brock Date: Wed, 26 Apr 2023 00:51:02 -0400 Subject: [PATCH] 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 --- share/chruby/chruby.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/share/chruby/chruby.sh b/share/chruby/chruby.sh index 7b2b4895..76b5ed89 100644 --- a/share/chruby/chruby.sh +++ b/share/chruby/chruby.sh @@ -2,9 +2,10 @@ CHRUBY_VERSION="0.3.9" RUBIES=() for dir in "$PREFIX/opt/rubies" "$HOME/.rubies"; do - [[ -d "$dir" && -n "$(command ls -A "$dir")" ]] && RUBIES+=("$dir"/*) + [[ -d "$dir" ]] && dir_contents=("$dir"/*) && \ + [[ ${#dir_contents[@]} -gt 0 ]] && RUBIES+=(${dir_contents[@]}) done -unset dir +unset dir dir_contents function chruby_reset() {