<commit_before># ------------------------------------------------------------------------------
# ~zozo/.config/bash/functions/pid.bash
# ------------------------------------------------------------------------------

case $OSTYPE in
    cygwin)  flags_pid='-asW' ;;
    *)       flags_pid='-cx -o pid,command' ;;
esac

pidof()
{   # return the PID of process $1
    declare proc="$1"
    command ps $flags_pid |
    egrep -io "\<[[:digit:]]+ .*\<$proc[^\\]*(\.exe)?$" |
    cut -d" " -f1
}

pidis()
{   # return the process with PID $1
    declare pid="$1"
    command ps ${flags_pid/pid,/} -p $pid  |
    tail -n+2
}<commit_msg>Exit 1 if PID/process isn't found<commit_after># ------------------------------------------------------------------------------
# ~zozo/.config/bash/functions/pid.bash
# ------------------------------------------------------------------------------

case $OSTYPE in
    cygwin)  flags_pid='-asW' ;;
    *)       flags_pid='-cx -o pid,command' ;;
esac

pidof()
{   # return the PID of process $1 or exit false
    declare proc="$1" pid

    pid=$(command ps $flags_pid |
        egrep -io "\<[[:digit:]]+ .*\<$proc[^\\]*(\.exe)?$" |
        cut -d" " -f1)
    
    [[ $pid ]] && echo "$pid"
}

pidis()
{   # return the process with PID $1 or exit false
    declare pid="$1" proc
    proc=$(command ps ${flags_pid/pid,/} -p $pid  |
        tail -n+2)

    [[ $proc ]] && echo "$proc"
}
{'fraction_non_alphanumeric': 0.38075017692852087, 'fraction_numerical': 0.009200283085633405, 'mean_word_length': 1.2163009404388714, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '7212544', 'n_tokens_mistral': 464, 'n_tokens_neox': 442, 'n_words': 111}