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

# helpers
#
# useful utility functions for osx.bash
# --------

# asks the user to approve or deny something
#
# params:
#   prompt - what to ask the user to approve
#
# usage: prompt_user prompt
#
# returns:
#   0 - if reply is Y or y
#   1 - if reply is anything else
#
function prompt_user() {
    if [ -z "$1" ]; then
        echo "Usage: ${FUNCNAME[0]} prompt"
        return 1
    fi

    read -r -e -p "$1 "
    echo ""

    if [[ "$REPLY" =~ ^[Yy]$ ]]; then
        return 0
    fi

    return 1
}

# installs or upgrades a brew package if needed
#
# params:
#   package: brew package to install
#
# usage: brew_install package
#
function brew_install() {
    if [ -z "$1" ]; then
        echo "Usage: ${FUNCNAME[0]} package"
        return 1
    fi

    if brew ls --versions "$1" &> /dev/null; then
        if brew outdated | grep "$1" &> /dev/null; then
            brew upgrade "$1"
        fi
    else
        brew install "$1"
    fi
}

# installs or upgrades a brew cask app
#
# params:
#   package: mac app to install
#
# usage: brew_cask_install package
#
function brew_cask_install() {
    if [ -z "$1" ]; then
        echo "Usage: ${FUNCNAME[0]} package"
        return 1
    fi

    if brew cask ls --versions "$1" &> /dev/null; then
        brew cask reinstall "$1"
    else
        brew cask install "$1"
    fi
}

# checks if computer can run the osx.bash script
#
# returns:
#   0 - if $OS == $VERSION
#   1 - otherwise
#
function os_eligible() {
    VERSION="10.12"
    PREV_VERSION="10.11"
    OS=$(sw_vers -productVersion | awk -F '.' '{print $1 "." $2}')
<commit_msg>Bump version in helpers.bash<commit_after>#!/usr/bin/env bash

# helpers
#
# useful utility functions for osx.bash
# --------

# asks the user to approve or deny something
#
# params:
#   prompt - what to ask the user to approve
#
# usage: prompt_user prompt
#
# returns:
#   0 - if reply is Y or y
#   1 - if reply is anything else
#
function prompt_user() {
    if [ -z "$1" ]; then
        echo "Usage: ${FUNCNAME[0]} prompt"
        return 1
    fi

    read -r -e -p "$1 "
    echo ""

    if [[ "$REPLY" =~ ^[Yy]$ ]]; then
        return 0
    fi

    return 1
}

# installs or upgrades a brew package if needed
#
# params:
#   package: brew package to install
#
# usage: brew_install package
#
function brew_install() {
    if [ -z "$1" ]; then
        echo "Usage: ${FUNCNAME[0]} package"
        return 1
    fi

    if brew ls --versions "$1" &> /dev/null; then
        if brew outdated | grep "$1" &> /dev/null; then
            brew upgrade "$1"
        fi
    else
        brew install "$1"
    fi
}

# installs or upgrades a brew cask app
#
# params:
#   package: mac app to install
#
# usage: brew_cask_install package
#
function brew_cask_install() {
    if [ -z "$1" ]; then
        echo "Usage: ${FUNCNAME[0]} package"
        return 1
    fi

    if brew cask ls --versions "$1" &> /dev/null; then
        brew cask reinstall "$1"
    else
        brew cask install "$1"
    fi
}

# checks if computer can run the osx.bash script
#
# returns:
#   0 - if $OS == $VERSION
#   1 - otherwise
#
function os_eligible() {
    VERSION="10.13"
    PREV_VERSION="10.12"
    OS=$(sw_vers -productVersion | awk -F '.' '{print $1 "." $2}')

{'fraction_non_alphanumeric': 0.13579493439121149, 'fraction_numerical': 0.02014037229173024, 'mean_word_length': 2.1671497584541064, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4588155', 'n_tokens_mistral': 1173, 'n_tokens_neox': 1111, 'n_words': 395}