<commit_before>#!/usr/bin/sh

# Platform variables

# https://unix.stackexchange.com/questions/23833
# https://unix.stackexchange.com/questions/432816
# https://stackoverflow.com/questions/20007288

# Useful files to parse:
# > cat /etc/os-release
# > cat /proc/version

# Get OS name from `/etc/os-release`:
# - `-F=`: Tell awk to use = as separator.
# - `$1=="ID"`: Filter on ID.
# - `{ print $2 ;}`: Print value.

# Strip quotes:
# > sed 's/"//g'
# > tr -d \"
# > tr -cd '[:alnum:]'



# Operating system                                                          {{{1
# ==============================================================================

KOOPA_OS_NAME="$( \
    awk -F= '$1=="ID" { print $2 ;}' /etc/os-release | \
    tr -cd '[:alnum:]' \
)"
export KOOPA_OS_NAME

KOOPA_OS_VERSION="$( \
    awk -F= '$1=="VERSION_ID" { print $2 ;}' /etc/os-release | \
    tr -cd '[:digit:].' \
)"
export KOOPA_OS_VERSION


<commit_msg>Update platform to work on macOS<commit_after>#!/usr/bin/sh

# Platform variables

# https://unix.stackexchange.com/questions/23833
# https://unix.stackexchange.com/questions/432816
# https://stackoverflow.com/questions/20007288

# Useful files to parse:
# > cat /etc/os-release
# > cat /proc/version

# For macOS, use this approach instead for OS variables:
# https://apple.stackexchange.com/questions/255546

# Get OS name from `/etc/os-release`:
# - `-F=`: Tell awk to use = as separator.
# - `$1=="ID"`: Filter on ID.
# - `{ print $2 ;}`: Print value.

# Strip quotes:
# > sed 's/"//g'
# > tr -d \"
# > tr -cd '[:alnum:]'



# Operating system                                                          {{{1
# ==============================================================================

os="$(uname -s)"
# rev="$(uname -r)"
# mach="$(uname -m)"

if [ "$os" = "Darwin" ]
then
    OIFS="$IFS"
    IFS=$'\n'
    set $(sw_vers) > /dev/null
    KOOPA_OS_NAME="$(echo $1 | tr "\n" ' ' | sed 's/ProductName:[ ]*//')"
    KOOPA_OS_VERSION="$(echo $2 | tr "\n" ' ' | sed 's/ProductVersion:[ ]*//')"
    IFS="$OIFS"
else
    os_file="/etc/os-release"
    KOOPA_OS_NAME="$( \
        awk -F= '$1=="ID" { print $2 ;}' "$os_file" | \
        tr -cd '[:alnum:]' \
    )"
    KOOPA_OS_VERSION="$( \
        awk -F= '$1=="VERSION_ID" { print $2 ;}' "$os_file" | \
        tr -cd '[:digit:].' \
    )"
    unset -v os_file
fi

export KOOPA_OS_NAME
export KOOPA_OS_VERSION

unset -v os



{'fraction_non_alphanumeric': 0.25861353258613534, 'fraction_numerical': 0.024906600249066, 'mean_word_length': 2.5916542473919524, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6517122', 'n_tokens_mistral': 974, 'n_tokens_neox': 883, 'n_words': 192}