Repository: nvm-sh/nvm
File: nvm.sh (Shell)

Code before:
      nvm_print_versions "$NVM_LS_OUTPUT"
      return $NVM_LS_EXIT_CODE
    ;;
    "current" )
      nvm_version current
    ;;
    "alias" )
      mkdir -p "$NVM_DIR/alias"
      if [ $# -le 2 ]; then
        local DEST
        for ALIAS_PATH in "$NVM_DIR"/alias/"$2"*; do
          ALIAS="$(basename "$ALIAS_PATH")"
          DEST="$(nvm_alias "$ALIAS" 2> /dev/null)"
          if [ -n "$DEST" ]; then
            VERSION="$(nvm_version "$DEST")"
            if [ "_$DEST" = "_$VERSION" ]; then
              echo "$ALIAS -> $DEST"
            else
              echo "$ALIAS -> $DEST (-> $VERSION)"
            fi
          fi
        done

        for ALIAS in "stable" "unstable"; do
          if [ ! -f "$NVM_DIR/alias/$ALIAS" ]; then
            if [ $# -lt 2 ] || [ "~$ALIAS" = "~$2" ]; then
              DEST="$(nvm_print_implicit_alias local "$ALIAS")"
              if [ "_$DEST" != "_" ]; then
                VERSION="$(nvm_version "$DEST")"
                echo "$ALIAS -> $DEST (-> $VERSION) (default)"
              fi
            fi
          fi
        done
        return
      fi
      if [ -z "$3" ]; then
        rm -f "$NVM_DIR/alias/$2"
        echo "$2 -> *poof*"
        return
      fi
      VERSION="$(nvm_version "$3")"
      if [ $? -ne 0 ]; then
        echo "! WARNING: Version '$3' does not exist." >&2
      fi
      echo $3 > "$NVM_DIR/alias/$2"
      if [ ! "_$3" = "_$VERSION" ]; then
        echo "$2 -> $3 (-> $VERSION)"
      else
        echo "$2 -> $3"
      fi

Review comment (suggestion):
This line should be `echo "$(nvm use system 2>&1 >/dev/null && dirname "$(which node)")"`.

Note the removed "echo", the suppression of `nvm use system` output, and the double quotes around paths that could contain spaces.


Code after:
      NVM_LS_EXIT_CODE=$?
      nvm_print_versions "$NVM_LS_OUTPUT"
      return $NVM_LS_EXIT_CODE
    ;;
    "current" )
      nvm_version current
    ;;
    "which" )
      if [ $# -eq 1 ]; then
        nvm_rc_version
        if [ -n "$NVM_RC_VERSION" ]; then
          VERSION=$(nvm_version $NVM_RC_VERSION)
        fi
      elif [ "_$2" != '_system' ]; then
        VERSION="$(nvm_version "$2")"
      else
        VERSION="$2"
      fi
      if [ -z "$VERSION" ]; then
        nvm help
        return 127
      fi

      if [ "_$VERSION" = '_system' ]; then
        if nvm_has_system_node >/dev/null 2>&1; then
          echo $(nvm use system && echo dirname $(which node))
          return
        else
          echo "System version of node not found." >&2
          return 127
        fi
      elif [ "_$VERSION" = "_∞" ]; then
        echo "The alias \"$2\" leads to an infinite loop. Aborting." >&2
        return 8
      fi

      local NVM_VERSION_DIR
      NVM_VERSION_DIR="$(nvm_version_path "$VERSION")"
      if [ ! -d "$NVM_VERSION_DIR" ]; then
        echo "$VERSION version is not installed yet" >&2
        return 1
      fi
      echo $NVM_DIR/$VERSION/bin
    ;;
    "alias" )
      mkdir -p "$NVM_DIR/alias"
      if [ $# -le 2 ]; then
        local DEST
        for ALIAS_PATH in "$NVM_DIR"/alias/"$2"*; do
          ALIAS="$(basename "$ALIAS_PATH")"
          DEST="$(nvm_alias "$ALIAS" 2> /dev/null)"