<commit_before>#!/bin/sh
# Copyright 2017 <NAME> and Nim developers.
#
# Licensed under the BSD-3-Clause license.
#
# This script performs some platform detection, downloads the latest version
# of choosenim and initiates its installation.

set -u
set -e

url_prefix="https://github.com/dom96/choosenim/releases/download/"

temp_prefix="${TMPDIR:-/tmp}"

CHOOSE_VERSION="${CHOOSENIM_CHOOSE_VERSION:-stable}"

need_tty=yes
debug=""

has_curl() {
  command -v curl >/dev/null 2>&1
}

has_wget() {
  command -v wget >/dev/null 2>&1
}

install() {
  get_platform || return 1
  local platform=$RET_VAL
  local stable_version=
  if has_curl; then
    stable_version=`curl -sSfL https://nim-lang.org/choosenim/stable`
  elif has_wget; then
    stable_version=`wget -qO - https://nim-lang.org/choosenim/stable`
  fi
  local filename="choosenim-$stable_version"_"$platform"
  local url="$url_prefix"v"$stable_version/$filename"
  local ext=""

  case $platform in
    *macosx_amd64* | *linux_amd64* )
      ;;
    *windows_amd64* )
      # Download ZIP for Windows
      local ext=".exe"
      local filename="$filename$ext"
      local url="$url$ext"
      ;;
    * )
      say_err "Sorry, your platform ($platform) is not supported by choosenim."
      say_err "You will need to install Nim using an alternative method."
      say_err "See the following link for more info: https://nim-lang.org/install.html"
      exit 1
      ;;
  esac

  say "Downloading $filename"
  if has_curl; then
    curl -sSfL "$url" -o "$temp_prefix/$filename"
  elif has_wget; then
    wget -qO "$temp_prefix/$filename" "$url"
  fi
  chmod +x "$temp_prefix/$filename"

  if [ "$need_tty" = "yes" ]; then
    # The installer is going to want to ask for confirmation by
    # reading stdin.  This script was piped into `sh` though and
    # doesn't have stdin to pass to its children. Instead we're going
    # to explicitly connect /dev/tty to the installer's stdin.
    if [ ! -t 1 ]; then
      err "Unable to run interactively. Run with -y to accept defaults."
    fi

    # Install Nim from desired channel.
    "$temp_prefix/$filename" $CHOOSE_VERSION --firstInstall ${debug} < /dev/tty
  else
    "$temp_prefix/$filename" $CHOOSE_VERSION --firstInstall -y ${debug}
  fi

  # Copy choosenim binary to Nimble bin.
  local nimbleBinDir=`"$temp_prefix/$filename" --getNimbleBin`
  cp "$temp_prefix/$filename" "$nimbleBinDir/choosenim$ext"
  say "ChooseNim installed in $nimbleBinDir"
  say "You must now ensure that the Nimble bin dir is in your PATH."
  if [ "$platform" != "windows_amd64" ]; then
    say "Place the following line in the ~/.profile or ~/.bashrc file."
    say "    export PATH=$nimbleBinDir:\$PATH"
    case "$SHELL" in
      *fish*)
      say "Running fish shell?"
      say "set -ga fish_user_paths $nimbleBinDir"
    ;;
    esac
  fi
}<commit_msg>Fixes init.sh script crash when $SHELL not set. Fixes #274.<commit_after>#!/bin/sh
# Copyright 2017 <NAME> and Nim developers.
#
# Licensed under the BSD-3-Clause license.
#
# This script performs some platform detection, downloads the latest version
# of choosenim and initiates its installation.

set -u
set -e

url_prefix="https://github.com/dom96/choosenim/releases/download/"

temp_prefix="${TMPDIR:-/tmp}"

CHOOSE_VERSION="${CHOOSENIM_CHOOSE_VERSION:-stable}"

need_tty=yes
debug=""

has_curl() {
  command -v curl >/dev/null 2>&1
}

has_wget() {
  command -v wget >/dev/null 2>&1
}

install() {
  get_platform || return 1
  local platform=$RET_VAL
  local stable_version=
  if has_curl; then
    stable_version=`curl -sSfL https://nim-lang.org/choosenim/stable`
  elif has_wget; then
    stable_version=`wget -qO - https://nim-lang.org/choosenim/stable`
  fi
  local filename="choosenim-$stable_version"_"$platform"
  local url="$url_prefix"v"$stable_version/$filename"
  local ext=""

  case $platform in
    *macosx_amd64* | *linux_amd64* )
      ;;
    *windows_amd64* )
      # Download ZIP for Windows
      local ext=".exe"
      local filename="$filename$ext"
      local url="$url$ext"
      ;;
    * )
      say_err "Sorry, your platform ($platform) is not supported by choosenim."
      say_err "You will need to install Nim using an alternative method."
      say_err "See the following link for more info: https://nim-lang.org/install.html"
      exit 1
      ;;
  esac

  say "Downloading $filename"
  if has_curl; then
    curl -sSfL "$url" -o "$temp_prefix/$filename"
  elif has_wget; then
    wget -qO "$temp_prefix/$filename" "$url"
  fi
  chmod +x "$temp_prefix/$filename"

  if [ "$need_tty" = "yes" ]; then
    # The installer is going to want to ask for confirmation by
    # reading stdin.  This script was piped into `sh` though and
    # doesn't have stdin to pass to its children. Instead we're going
    # to explicitly connect /dev/tty to the installer's stdin.
    if [ ! -t 1 ]; then
      err "Unable to run interactively. Run with -y to accept defaults."
    fi

    # Install Nim from desired channel.
    "$temp_prefix/$filename" $CHOOSE_VERSION --firstInstall ${debug} < /dev/tty
  else
    "$temp_prefix/$filename" $CHOOSE_VERSION --firstInstall -y ${debug}
  fi

  # Copy choosenim binary to Nimble bin.
  local nimbleBinDir=`"$temp_prefix/$filename" --getNimbleBin`
  cp "$temp_prefix/$filename" "$nimbleBinDir/choosenim$ext"
  say "ChooseNim installed in $nimbleBinDir"
  say "You must now ensure that the Nimble bin dir is in your PATH."
  if [ "$platform" != "windows_amd64" ]; then
    say "Place the following line in the ~/.profile or ~/.bashrc file."
    say "    export PATH=$nimbleBinDir:\$PATH"
    case "${SHELL:=sh}" in
      *fish*)
      say "Running fish shell?"
      say "set -ga fish_user_paths $nimbleBinDir"
    ;;
    esac
  fi
}
{'fraction_non_alphanumeric': 0.12116457461645747, 'fraction_numerical': 0.008193863319386332, 'mean_word_length': 3.2654275092936804, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '902436', 'n_tokens_mistral': 1994, 'n_tokens_neox': 1905, 'n_words': 585}