<commit_before>#!/usr/bin/env bash
# useful utilities


# modules
msu_require "console"
msu_require "format"
msu_require "metadata"


# module variables
{
  # shellcheck disable=2034
  DEPS="git"
}

# upgrade myself
function upgrade() {
  log "upgrading myself"
  LIB=${MSU_INSTALL_LIB:-$(dirname "${MSU_LIB}")}
  BIN=${MSU_INSTALL_BIN:-$(dirname "$(which msu)")}
  MAN=${MSU_INSTALL_MAN}
  if [ ! "${MAN}" ]
  then
    for path in ${MANPATH//\:/\n}
    do
      if [ -f "${path}/man1/msu.1" ]
      then
        MAN=${path}
        break
      fi
    done
  fi

  if [ "${1}" ]
  then
    head=$(echo "${1}" | tr '[:upper:]' '[:lower:]')
    case "${head}" in
      "head" )
        wget -qO- http://git.io/vTE0s | LIB="${LIB}" BIN="${BIN}" MAN="${MAN}" bash
      ;;
      * )
        version="${1}"
      ;;
    esac
    [ ! "${version}" ] && return
  fi

  # upgrade using tarball
  pushd /tmp > /dev/null
  [ ! "${version}" ] && {
    version=$(python "${MSU_LIB}/get-latest-version.py" "${MSU_VERSION}")
    status=$?
    case "${status}" in
      1 )
        log "you have the latest version: ${version}"
      ;;
      2 )
        error "required python dependencies are missing"
      ;;
      3 )
        error "network request error"
      ;;
    esac
    [ "${status}" -ne 0 ] && exit ${status}
  }
  wget "https://github.com/GochoMugo/msu/releases/download/${version}/msu-${version}.tar.gz" -q > /dev/null
  tar xvf "msu-${version}.tar.gz" > /dev/null 2>&1
  cd "msu-${version}" || {
    error "could not \`cd' into directory with extracted contents"
    return 1
  }
  LIB="${LIB}" BIN="${BIN}" MAN="${MAN}" ./install.sh
  popd > /dev/null
}

<commit_msg>(core_utils) Fix console output of 'upgrade'<commit_after>#!/usr/bin/env bash
# useful utilities


# modules
msu_require "console"
msu_require "format"
msu_require "metadata"


# module variables
{
  # shellcheck disable=2034
  DEPS="git"
}

# upgrade myself
function upgrade() {
  log "upgrading myself"
  LIB=${MSU_INSTALL_LIB:-$(dirname "${MSU_LIB}")}
  BIN=${MSU_INSTALL_BIN:-$(dirname "$(which msu)")}
  MAN=${MSU_INSTALL_MAN}
  if [ ! "${MAN}" ]
  then
    for path in ${MANPATH//\:/\n}
    do
      if [ -f "${path}/man1/msu.1" ]
      then
        MAN=${path}
        break
      fi
    done
  fi

  if [ "${1}" ]
  then
    head=$(echo "${1}" | tr '[:upper:]' '[:lower:]')
    case "${head}" in
      "head" )
        wget -qO- http://git.io/vTE0s | LIB="${LIB}" BIN="${BIN}" MAN="${MAN}" bash
      ;;
      * )
        version="${1}"
      ;;
    esac
    [ ! "${version}" ] && return
  fi

  # upgrade using tarball
  pushd /tmp > /dev/null
  [ ! "${version}" ] && {
    version=$(python "${MSU_LIB}/get-latest-version.py" "${MSU_VERSION}")
    status=$?
    case "${status}" in
      1 )
        log "you have the latest version"
      ;;
      2 )
        error "required python dependencies are missing"
      ;;
      3 )
        error "network request error"
      ;;
    esac
    [ "${status}" -ne 0 ] && exit ${status}
  }
  wget "https://github.com/GochoMugo/msu/releases/download/${version}/msu-${version}.tar.gz" -q > /dev/null
  tar xvf "msu-${version}.tar.gz" > /dev/null 2>&1
  cd "msu-${version}" || {
    error "could not \`cd' into directory with extracted contents"
    return 1
  }
  LIB="${LIB}" BIN="${BIN}" MAN="${MAN}" ./install.sh
  popd > /dev/null
}


{'fraction_non_alphanumeric': 0.1977956508787608, 'fraction_numerical': 0.01012809055704498, 'mean_word_length': 2.444102564102564, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2529834', 'n_tokens_mistral': 1265, 'n_tokens_neox': 1202, 'n_words': 280}