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

Code before:
      local REINSTALL_PACKAGES_FROM
      local SKIP_DEFAULT_PACKAGES

      while [ $# -ne 0 ]
      do
        case "$1" in
          --reinstall-packages-from=*)
            PROVIDED_REINSTALL_PACKAGES_FROM="$(nvm_echo "$1" | command cut -c 27-)"
            REINSTALL_PACKAGES_FROM="$(nvm_version "$PROVIDED_REINSTALL_PACKAGES_FROM")" ||:
          ;;
          --copy-packages-from=*)
            PROVIDED_REINSTALL_PACKAGES_FROM="$(nvm_echo "$1" | command cut -c 22-)"
            REINSTALL_PACKAGES_FROM="$(nvm_version "$PROVIDED_REINSTALL_PACKAGES_FROM")" ||:
          ;;
          --skip-default-packages)
            SKIP_DEFAULT_PACKAGES=true ||:
          ;;
          *)
            ADDITIONAL_PARAMETERS="$ADDITIONAL_PARAMETERS $1"
          ;;
        esac
        shift
      done

      if [ -z "$SKIP_DEFAULT_PACKAGES" ] && [ -f "${NVM_DIR}/default-packages" ]; then
        local DEFAULT_PACKAGES=""

        # Read lines from $NVM_DIR/default-packages
        local line
        while IFS=" " read -r -a line; do

          # Skip empty lines.
          [ -z "${line}" ] || continue

          # Skip comment lines that begin with `#`.
          [ "${line:0:1}" != "#" ] || continue

          # Fail on lines that have multiple space-separated words
          case ${VAR} in
            *\ * )
              nvm_echo "Only one package per line is allowed in the ${NVM_DIR}/default-packages file. Please remove any lines with multiple space-seperated values."
              return 1
            ;;
          esac

          DEFAULT_PACKAGES="${DEFAULT_PACKAGES}${line} "
        done < "${NVM_DIR}/default-packages"

        if [ -z "$DEFAULT_PACKAGES" ]; then
          nvm_echo "Installing default global packages from ${NVM_DIR}/default-packages..."
          { 

Review comment (suggestion):
please always declare `local` vars in a separate line from initializing them; this line as-is won't work in `ksh` which doesn't support `local`.

Code after:
          LTS_MSG='(with LTS filter) '
          REMOTE_CMD='nvm ls-remote --lts'
        elif [ -n "${LTS-}" ]; then
          LTS_MSG="(with LTS filter '$LTS') "
          REMOTE_CMD="nvm ls-remote --lts=${LTS}"
        else
          REMOTE_CMD='nvm ls-remote'
        fi
        nvm_err "Version '$provided_version' ${LTS_MSG-}not found - try \`${REMOTE_CMD}\` to browse available versions."
        return 3
      fi

      ADDITIONAL_PARAMETERS=''
      local PROVIDED_REINSTALL_PACKAGES_FROM
      local REINSTALL_PACKAGES_FROM
      local SKIP_DEFAULT_PACKAGES
      local DEFAULT_PACKAGES

      while [ $# -ne 0 ]
      do
        case "$1" in
          --reinstall-packages-from=*)
            PROVIDED_REINSTALL_PACKAGES_FROM="$(nvm_echo "$1" | command cut -c 27-)"
            REINSTALL_PACKAGES_FROM="$(nvm_version "$PROVIDED_REINSTALL_PACKAGES_FROM")" ||:
          ;;
          --copy-packages-from=*)
            PROVIDED_REINSTALL_PACKAGES_FROM="$(nvm_echo "$1" | command cut -c 22-)"
            REINSTALL_PACKAGES_FROM="$(nvm_version "$PROVIDED_REINSTALL_PACKAGES_FROM")" ||:
          ;;
          --skip-default-packages)
            SKIP_DEFAULT_PACKAGES=true
          ;;
          *)
            ADDITIONAL_PARAMETERS="$ADDITIONAL_PARAMETERS $1"
          ;;
        esac
        shift
      done

      if [ -z "$SKIP_DEFAULT_PACKAGES" ] && [ -f "${NVM_DIR}/default-packages" ]; then
        DEFAULT_PACKAGES=""

        # Read lines from $NVM_DIR/default-packages
        local line
        while IFS=" " read -r line; do
          # Skip empty lines.
          [ -n "${line}" ] || continue

          # Skip comment lines that begin with `#`.
          [ "$(echo "$line" | cut -c1)" != "#" ] || continue