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

Code before:
    "debug" )
      local ZSH_HAS_SHWORDSPLIT_UNSET
      ZSH_HAS_SHWORDSPLIT_UNSET=1
      if nvm_has "setopt"; then
        ZSH_HAS_SHWORDSPLIT_UNSET="$(set +e ; setopt | nvm_grep shwordsplit > /dev/null ; nvm_echo $?)"
        setopt shwordsplit
      fi
      nvm_err "nvm --version: v$(nvm --version)"
      nvm_err "\$SHELL: $SHELL"
      nvm_err "\$HOME: $HOME"
      nvm_err "\$NVM_DIR: '$(nvm_sanitize_path "$NVM_DIR")'"
      nvm_err "\$PREFIX: '$(nvm_sanitize_path "$PREFIX")'"
      nvm_err "\$NPM_CONFIG_PREFIX: '$(nvm_sanitize_path "$NPM_CONFIG_PREFIX")'"
      nvm_err "\$NVM_NODEJS_ORG_MIRROR: '${NVM_NODEJS_ORG_MIRROR}'"
      nvm_err "\$NVM_IOJS_ORG_MIRROR: '${NVM_IOJS_ORG_MIRROR}'"
      nvm_err "shell version: '$(${SHELL} --version | command head -n 1)'"
      nvm_err "uname -a: '$(uname -a | awk '{$2=""; print}' | xargs)'"
      if [ "$(nvm_get_os)" = "darwin" ] && nvm_has sw_vers; then
        nvm_err "OS version: $(sw_vers | command awk '{print $2}' | command xargs)"
      elif [ -r "/etc/issue" ]; then
        nvm_err "OS version: $(command head -n 1 /etc/issue | command sed 's/\\.//g')"
      fi
      if nvm_has "curl"; then
        local CURL
        if type curl | command grep -q hashed; then
          CURL="$(type curl | command sed -E 's/\(|)//g' | command awk '{print $4}')"
        elif type curl | command grep -q aliased; then
          CURL="$(which curl) ($(type curl | command awk '{ $1=$2=$3=$4="" ;print }' | command sed 's/^\ *//g'))"
        else
          CURL="$(type curl)"
        fi
        nvm_err "curl: ${CURL}, $(command curl -V | command head -n 1)"
      fi
      if nvm_has "wget"; then
        local WGET
        if type wget | command grep -q hashed; then
          WGET="$(type wget | command sed -E 's/\(|)//g' | command awk '{print $4}')"
        elif type wget | command grep -q aliased; then
          WGET="$(which wget) ($(type wget | command awk '{ $1=$2=$3=$4="" ;print }' | command sed 's/^\ *//g'))"
        else
          WGET="$(type wget)"
        fi
        nvm_err "wget: ${WGET}, $(command wget -V | command head -n 1)"
      fi
      if nvm_has "git"; then
        local GIT
        if type git | command grep -q hashed; then
          GIT="$(type git | command sed -E 's/\(|)//g' | command awk '{print $4}')"
        elif type git | command grep -q aliased; then
          GIT="$(which git) ($(type git | command awk '{ $1=$2=$3=$4="" ;print }' | command sed 's/^\ *//g'))"
        else

Review comment (suggestion):
it seems like this logic is repeated three times; can we consolidate it into a `nvm_command_info` function? I'm thinking `CURL="$(nvm_command_info curl)"`

Code after:
        dir) nvm_cache_dir ;;
        clear)
          local DIR
          DIR="$(nvm_cache_dir)"
          if command rm -rf "${DIR}" && command mkdir -p "${DIR}"; then
            nvm_echo 'Cache cleared.'
          else
            nvm_err "Unable to clear cache: ${DIR}"
            return 1
          fi
        ;;
        *)
          >&2 nvm --help
          return 127
        ;;
      esac
    ;;

    "debug" )
      local ZSH_HAS_SHWORDSPLIT_UNSET
      ZSH_HAS_SHWORDSPLIT_UNSET=1
      if nvm_has "setopt"; then
        ZSH_HAS_SHWORDSPLIT_UNSET="$(set +e ; setopt | nvm_grep shwordsplit > /dev/null ; nvm_echo $?)"
        setopt shwordsplit
      fi
      nvm_err "nvm --version: v$(nvm --version)"
      nvm_err "\$SHELL: $SHELL"
      nvm_err "\$HOME: $HOME"
      nvm_err "\$NVM_DIR: '$(nvm_sanitize_path "$NVM_DIR")'"
      nvm_err "\$PREFIX: '$(nvm_sanitize_path "$PREFIX")'"
      nvm_err "\$NPM_CONFIG_PREFIX: '$(nvm_sanitize_path "$NPM_CONFIG_PREFIX")'"
      nvm_err "\$NVM_NODEJS_ORG_MIRROR: '${NVM_NODEJS_ORG_MIRROR}'"
      nvm_err "\$NVM_IOJS_ORG_MIRROR: '${NVM_IOJS_ORG_MIRROR}'"
      nvm_err "shell version: '$(${SHELL} --version | command head -n 1)'"
      nvm_err "uname -a: '$(uname -a | awk '{$2=""; print}' | xargs)'"
      if [ "$(nvm_get_os)" = "darwin" ] && nvm_has sw_vers; then
        nvm_err "OS version: $(sw_vers | command awk '{print $2}' | command xargs)"
      elif [ -r "/etc/issue" ]; then
        nvm_err "OS version: $(command head -n 1 /etc/issue | command sed 's/\\.//g')"
      fi
      if nvm_has "curl"; then
        nvm_err "curl: $(nvm_command_info curl), $(command curl -V | command head -n 1)"
      else
        nvm_err "curl: not found"
      fi
      if nvm_has "wget"; then
        nvm_err "wget: $(nvm_command_info wget), $(command wget -V | command head -n 1)"
      else
        nvm_err "wget: not found"
      fi
      if nvm_has "git"; then