From 6bfa3b3efb8fbc3c447fd5ca93b9f0c1f10563ad Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Sat, 14 Jun 2014 22:47:17 -0700 Subject: Handle empty directory correctly. --- rpath.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'rpath.sh') diff --git a/rpath.sh b/rpath.sh index 468df59..1f24420 100755 --- a/rpath.sh +++ b/rpath.sh @@ -42,8 +42,10 @@ _populate_dirs() { # Cannot handle paths containing a newline. Only an idiot would # encounter this in practice. - readarray -t dirs < \ - <(printf '%s\0' "${RUBIES_PATH}"/* | sort -zV | xargs -0n1) + readarray -t dirs < <(shopt -s nullglob; \ + printf '%s\0' "${RUBIES_PATH}"/* | sort -zV | xargs -0n1) + + [[ -n "${dirs}" ]] || _die "Directory ${RUBIES_PATH} is empty." } _match() { @@ -120,7 +122,7 @@ rpath_get() { } rpath_set() { - [[ -z "${1}" ]] && _die 'rpath set requires an argument.' + [[ -n "${1}" ]] || _die 'rpath set requires an argument.' _populate_dirs -- cgit v1.2.3-70-g09d2