<commit_before># Ubuntu-only stuff. Abort if not Ubuntu.
is_ubuntu || return 1

RG_VERSION="${1:-0.10.0}"

ignore_output() {
  "$@" > /dev/null 2>&1
}

binary_name() {
  local version="$1"
  echo "ripgrep-${version}_amd64.deb"
}

download_binary() {
  local version="$1"
  local bin_name=$(binary_name $version)

  curl \
    --location \
    --silent \
    --show-error \
    "https://github.com/BurntSushi/ripgrep/releases/download/$version/$bin_name" -o "$2/$bin_name"
}

downloaded_binary() {
  local version="$1"

  ignore_output command -v rg && rg --version | grep --quiet "$version"
}

install_linux() {
  local version="$1"

  if ! downloaded_binary $version; then
    echo "Installing rg v$version"

    tmp_dir=$(mktemp --directory)

    download_binary "$version" "$tmp_dir"

    sudo dpkg -i "$tmp_dir"/*.deb

    rm -rf $tmp_dir
  fi
}

main() {
  local version="${1:-$RG_VERSION}"
  local dist="$(uname -s)"

  case "$dist" in
    Linux)
      install_linux "$version"
      ;;
    *)
      echo "Don't know how to install rg on $dist"
      exit 1
  esac
}

main "$@"
<commit_msg>Fixed ripgrep version in script<commit_after># Ubuntu-only stuff. Abort if not Ubuntu.
is_ubuntu || return 1

RG_VERSION="0.10.0"

ignore_output() {
  "$@" > /dev/null 2>&1
}

binary_name() {
  local version="$1"
  echo
}

download_binary() {
  local version="$1"
  local bin_name=$(binary_name $version)

  curl \
    --location \
    --silent \
    --show-error \
    "https://github.com/BurntSushi/ripgrep/releases/download/$version/$bin_name" -o "$2/$bin_name"
}

downloaded_binary() {
  local version="$1"

  ignore_output command -v rg && rg --version | grep --quiet "$version"
}

install_linux() {
  local version="$1"
  local bin_name="ripgrep-${version}_amd64.deb"

  if ! downloaded_binary $version; then
    echo "Installing rg v$version"

    tmp_dir=$(mktemp --directory)

    download_binary "$version" "$bin_name" "$tmp_dir"

    sudo dpkg -i "$tmp_dir"/*.deb

    rm -rf $tmp_dir
  fi
}

install_windows() {
  local version="$1"
  local bin_name="ripgrep-${version}-x86_64-pc-windows-msvc.zip"

  if ! downloaded_binary $version; then
    echo "Installing rg v$version"

    tmp_dir=$(mktemp --directory)

    download_binary "$version" "$bin_name" "$tmp_dir"

    unzip "$tmp_dir"/*.zip

    #TODO move binary to correct location

    rm -rf $tmp_dir
  fi
}

main() {
  local version="$RG_VERSION"
  local dist="$(uname -s)"

  case "$dist" in
    Linux)
      install_linux "$version"
      ;;
    MINGW64_NT-10.0)
      install_windows "$version"
    *)
      echo "Don't know how to install rg on $dist"
      exit 1
  esac
}

main "$@"

{'fraction_non_alphanumeric': 0.15755748209574066, 'fraction_numerical': 0.0158311345646438, 'mean_word_length': 3.021212121212121, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3083145', 'n_tokens_mistral': 1040, 'n_tokens_neox': 946, 'n_words': 226}