Skip to content

Commit 9fc20bb

Browse files
committed
Merge pull request #710 from joliss/sed
Combine sed and grep commands
2 parents 3401d15 + 394e850 commit 9fc20bb

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

nvm.sh

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -603,17 +603,20 @@ nvm_ls() {
603603
fi
604604
if [ -n "$NVM_DIRS_TO_SEARCH" ]; then
605605
VERSIONS="$(command find $NVM_DIRS_TO_SEARCH -maxdepth 1 -type d -name "$PATTERN*" \
606-
| command sed "s#$NVM_VERSION_DIR_IOJS/#"$NVM_IOJS_PREFIX"-#" \
607-
| command grep -v "$NVM_VERSION_DIR_IOJS" \
608-
| command sed "s#^$NVM_DIR/##" \
609-
| command grep -v -e '^versions$' \
610-
| command sed 's#^versions/##' \
611-
| sed -e "s/^v/$NVM_NODE_PREFIX-v/" \
612-
| sed -e "s#^\($NVM_IOJS_PREFIX\)[-/]v#\1.v#" | sed -e "s#^\($NVM_NODE_PREFIX\)[-/]v#\1.v#" \
606+
| command sed "
607+
s#$NVM_VERSION_DIR_IOJS/#$NVM_IOJS_PREFIX-#;
608+
\#$NVM_VERSION_DIR_IOJS# d;
609+
s#^$NVM_DIR/##;
610+
\#^versions\$# d;
611+
s#^versions/##;
612+
s#^v#$NVM_NODE_PREFIX-v#;
613+
s#^\($NVM_IOJS_PREFIX\)[-/]v#\1.v#;
614+
s#^\($NVM_NODE_PREFIX\)[-/]v#\1.v#" \
613615
| command sort -t. -u -k 2.2,2n -k 3,3n -k 4,4n \
614616
| command sort -s -t- -k1.1,1.1 \
615-
| command sed "s/^\($NVM_IOJS_PREFIX\)\./\1-/" \
616-
| command sed "s/^$NVM_NODE_PREFIX\.//")"
617+
| command sed "
618+
s/^\($NVM_IOJS_PREFIX\)\./\1-/;
619+
s/^$NVM_NODE_PREFIX\.//")"
617620
fi
618621

619622
if [ $ZHS_HAS_SHWORDSPLIT_UNSET -eq 1 ] && nvm_has "unsetopt"; then

0 commit comments

Comments
 (0)