When none of the directories exist, don't `find` within them.

master
Jordan Harband 2015-02-20 23:12:00 -08:00
parent 12ca8f2607
commit cd481ff548
1 changed files with 14 additions and 12 deletions

26
nvm.sh
View File

@ -557,18 +557,20 @@ nvm_ls() {
if [ -z "$PATTERN" ]; then if [ -z "$PATTERN" ]; then
PATTERN='v' PATTERN='v'
fi fi
VERSIONS="$(command find $NVM_DIRS_TO_SEARCH -maxdepth 1 -type d -name "$PATTERN*" \ if [ -n "$NVM_DIRS_TO_SEARCH" ]; then
| command sed "s#$NVM_VERSION_DIR_IOJS/#"$NVM_IOJS_PREFIX"-#" \ VERSIONS="$(command find $NVM_DIRS_TO_SEARCH -maxdepth 1 -type d -name "$PATTERN*" \
| command grep -v "$NVM_VERSION_DIR_IOJS" \ | command sed "s#$NVM_VERSION_DIR_IOJS/#"$NVM_IOJS_PREFIX"-#" \
| command sed "s#^$NVM_DIR/##" \ | command grep -v "$NVM_VERSION_DIR_IOJS" \
| command grep -v -e '^versions$' \ | command sed "s#^$NVM_DIR/##" \
| command sed 's#^versions/##' \ | command grep -v -e '^versions$' \
| sed -e "s/^v/$NVM_NODE_PREFIX-v/" \ | command sed 's#^versions/##' \
| sed -e "s#^\($NVM_IOJS_PREFIX\)[-/]v#\1.v#" | sed -e "s#^\($NVM_NODE_PREFIX\)[-/]v#\1.v#" \ | sed -e "s/^v/$NVM_NODE_PREFIX-v/" \
| command sort -t. -u -k 2.2,2n -k 3,3n -k 4,4n \ | sed -e "s#^\($NVM_IOJS_PREFIX\)[-/]v#\1.v#" | sed -e "s#^\($NVM_NODE_PREFIX\)[-/]v#\1.v#" \
| command sort -s -t- -k1.1,1.1 \ | command sort -t. -u -k 2.2,2n -k 3,3n -k 4,4n \
| command sed "s/^\($NVM_IOJS_PREFIX\)\./\1-/" \ | command sort -s -t- -k1.1,1.1 \
| command sed "s/^$NVM_NODE_PREFIX\.//")" | command sed "s/^\($NVM_IOJS_PREFIX\)\./\1-/" \
| command sed "s/^$NVM_NODE_PREFIX\.//")"
fi
if [ $ZHS_HAS_SHWORDSPLIT_UNSET -eq 1 ] && nvm_has "unsetopt"; then if [ $ZHS_HAS_SHWORDSPLIT_UNSET -eq 1 ] && nvm_has "unsetopt"; then
unsetopt shwordsplit unsetopt shwordsplit