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

source variables.sh
source functions.sh

# TODO: Prettify the version check for better readability
# Simple script to list version numbers of critical development tools

echo warn "Checking system..."
echo empty
echo warn "Bash:        ${BOLD}$(bash --version | head -n1 | cut -d"(" -f1 | cut -d" " -f4)${NORM}"
echo warn "Binutils:    ${BOLD}$(ld --version | head -n1 | cut -d" " -f7)${NORM}"
echo warn "Bison:       ${BOLD}$(bison --version | head -n1 | cut -d" " -f4)${NORM}"
echo warn "Bzip2:       ${BOLD}$(bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d" " -f8 | cut -d"," -f1)${NORM}"
echo warn "Coreutils:   ${BOLD}$(chown --version | head -n1 | cut -d" " -f4)${NORM}"
echo warn "Diffutils:   ${BOLD}$(diff --version | head -n1 | cut -d" " -f4)${NORM}"
echo warn "Findutils:   ${BOLD}$(find --version | head -n1 | cut -d" " -f4)${NORM}"
echo warn "Gawk:        ${BOLD}$(gawk --version | head -n1 | cut -d" " -f3)${NORM}"
echo warn "GCC:         ${BOLD}$(gcc --version | head -n1 | cut -d" " -f4)${NORM}"
echo warn "G++:         ${BOLD}$(g++ --version | head -n1 | cut -d" " -f4)${NORM}"
echo warn "Glibc:       ${BOLD}$(ldd $(which ${SHELL}) | grep libc.so | cut -d ' ' -f 3 | ${SHELL} | head -n 1 | cut -d ' ' -f 1-7 | cut -d" " -f6 | cut -d"-" -f1)${NORM}"
echo warn "Grep:        ${BOLD}$(grep --version | head -n1 | cut -d" " -f4)${NORM}"
echo warn "Gzip:        ${BOLD}$(gzip --version | head -n1 | cut -d" " -f2)${NORM}"
echo warn "Make:        ${BOLD}$(make --version | head -n1 | cut -d" " -f3)${NORM}"
echo warn "Ncurses:     ${BOLD}$(tic -V | cut -d" " -f2)${NORM}"
echo warn "Patch:       ${BOLD}$(patch --version | head -n1 | cut -d" " -f3)${NORM}"
echo warn "Sed:         ${BOLD}$(sed --version | head -n1 | cut -d" " -f4)${NORM}"
echo warn "Tar:         ${BOLD}$(tar --version | head -n1 | cut -d" " -f4)${NORM}"
echo warn "Makeinfo:    ${BOLD}$(makeinfo --version | head -n1 | cut -d" " -f4)${NORM}"
echo warn "Xz-utils:    ${BOLD}$(xz --version | head -n1 | cut -d" " -f4)${NORM}"

echo norm 'int main(){}' | gcc -v -o /dev/null -x c - > dummy.log 2>&1

if ! grep -q ' error' dummy.log; then
    echo success "Compilation successful" && rm dummy.log
else
    echo error "Compilation FAILED. If you like, you can also view dummy.log for more details."
    exit 1
fi<commit_msg>Simplified version checking<commit_after>#!/usr/bin/env bash

source variables.sh
source functions.sh

#-----------------------------------------------------------------------------------------------------------------------
#                               M I N I M U M   H O S T   R E Q U I R E M E N T S
#-----------------------------------------------------------------------------------------------------------------------
BASH_MIN_REQ="2.05"
BINUTILS_MIN_REQ="2.12"
BISON_MIN_REQ="1.875"
BZIP2_MIN_REQ="1.0.2"
COREUTILS_MIN_REQ="5.0"
DIFFUTILS_MIN_REQ="2.8"
FINDUTILS_MIN_REQ="4.1.20"
GAWK_MIN_REQ="3.1.5"
GCC_MIN_REQ="4.1.2"
GCC_MAX_REQ="4.8.3"
GLIBC_MIN_REQ="2.2.5"
GLIBC_MAX_REQ="2.19"
GREP_MIN_REQ="2.5"
GZIP_MIN_REQ="1.2.4"
MAKE_MIN_REQ="3.80"
NCURSES_MIN_REQ="5.3"
PATCH_MIN_REQ="2.5.4"
SED_MIN_REQ="3.0.2"
TAR_MIN_REQ="1.22"
TEXINFO_MIN_REQ="4.7"
XZ_MIN_REQ="4.999.8"

#-----------------------------------------------------------------------------------------------------------------------
#                                     C U R R E N T   V E R S I O N S
#-----------------------------------------------------------------------------------------------------------------------
BASH_CURR=$(bash --version | head -n1 | cut -d"(" -f1 | cut -d" " -f4)
BINUTILS_CURR=$(ld --version | head -n1 | cut -d" " -f7)
BISON_CURR=$(bison --version | head -n1 | cut -d" " -f4)
BZIP2_CURR=$(bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d" " -f8 | cut -d"," -f1)
COREUTILS_CURR=$(chown --version | head -n1 | cut -d" " -f4)
DIFFUTILS_CURR=$(diff --version | head -n1 | cut -d" " -f4)
FINDUTILS_CURR=$(find --version | head -n1 | cut -d" " -f4)
GAWK_CURR=$(gawk --version | head -n1 | cut -d" " -f3)
GCC_CURR=$(gcc --version | head -n1 | cut -d" " -f4)
GLIBC_CURR=$(ldd $(which ${SHELL}) | grep libc.so | cut -d ' ' -f 3 | ${SHELL} | head -n 1 | cut -d ' ' -f 1-7 | cut -d" " -f6 | cut -d"-" -f1)
GREP_CURR=$(grep --version | head -n1 | cut -d" " -f4)
GZIP_CURR=$(gzip --version | head -n1 | cut -d" " -f2)
MAKE_CURR=$(make --version | head -n1 | cut -d" " -f3)
NCURSES_CURR=$(tic -V | cut -d" " -f2)
PATCH_CURR=$(patch --version | head -n1 | cut -d" " -f3)
SED_CURR=$(sed --version | head -n1 | cut -d" " -f4)
TAR_CURR=$(tar --version | head -n1 | cut -d" " -f4)
TEXINFO_CURR=$(makeinfo --version | head -n1 | cut -d" " -f4)
XZ_CURR=$(xz --version | head -n1 | cut -d" " -f4)

#-----------------------------------------------------------------------------------------------------------------------
#                                       V E R I F Y   R E Q U I R E M E N T S
#-----------------------------------------------------------------------------------------------------------------------

_list=(BASH BINUTILS BISON BZIP2 COREUTILS DIFFUTILS FINDUTILS GAWK GCC GLIBC GREP GZIP MAKE NCURSES PATCH SED TAR \
       TEXINFO XZ)

for progs in ${_list[@]}; do
    min="${progs}_MIN_REQ"
    cur="${progs}_CURR"

    if [ "$(printf "${!min}\n${!cur}" | sort -V | head -n1)" = "${!cur}" ] && [ "${!cur}" != "${!min}" ]; then
        echo error "$progs Found: v${!cur}, Required: v${!min}"
        exit 1
    fi
done

echo norm 'int main(){}' | gcc -v -o /dev/null -x c - > dummy.log 2>&1

if ! grep -q ' error' dummy.log; then
    rm dummy.log
else
    echo error "Compilation FAILED. If you like, you can also view dummy.log for more details."
    exit 0
fi
{'fraction_non_alphanumeric': 0.3063441990886786, 'fraction_numerical': 0.029442691903259727, 'mean_word_length': 1.7215069146399617, 'pattern_counts': {'":': 0, '<': 5, '<?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': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '759172', 'n_tokens_mistral': 2233, 'n_tokens_neox': 2144, 'n_words': 621}