<commit_before>#! /usr/bin/env bash
export MY_BIN="$HOME/bin" # 1. executable 2. does not concerns privacy

export MY_DOTFILES="$HOME/.dotfiles"
export MY_BUNDLED_BIN="$MY_DOTFILES/bin" # 1. executable/does not concerns privacy 2. built-in of this whole setup
export MY_SH="$MY_DOTFILES/sh"
export MY_RUNTIME="$MY_SH/runtime"
export MY_SH_MODULE="$MY_SH/module"

export MY_DOTFILES_RESOURCES="$HOME/.dotfiles_resources"
export MY_PRIVATE_BIN="$MY_DOTFILES_RESOURCES/bin" # 1. executable 2. concerns privacy 3. will be deleted in cleanup-process.

if [[ ! -d "$MY_BIN" ]];then
    mkdir -p "$MY_BIN"
fi

if [[ ! -d "$MY_DOTFILES_RESOURCES" ]];then
    mkdir -p "$MY_DOTFILES_RESOURCES"
fi

if [[ ! -d "$MY_PRIVATE_BIN" ]];then
    mkdir -p "$MY_PRIVATE_BIN"
fi

# reset to avoid issue causing by repeat sourcing
unset PATH
export PATH="/usr/bin:/bin:/usr/sbin:/sbin"
export PATH="$MY_BUNDLED_BIN:$PATH"
export PATH="$MY_PRIVATE_BIN:$PATH"

unset PROMPT_COMMAND

# for internal function, no `Usage`, only print log
_sh_log() {
    if [[ "$#" == 2 ]];then
        local LOG_DIR="$MY_DOTFILES/log"
        if [[ -d "$LOG_DIR" ]]; then
            echo "$(date +%Y-%m-%d-%H-%M-%S) [$1] : $2" >> $LOG_DIR/sh.log
        fi
    fi
}

_cache_gen() {
    # generate cache.bash, for cache.bash, those 'init.bash' just useless
    if [[ "$(echo $1 | grep init)" == '' ]];then
        # echo '[[ -r '"$file"' ]] && [[ -f '"$file"' ]] && source '"$1" >> "$MY_SH/cache.bash"
        # cut overhead as much as possible, so no checking for existence of each file, if anything goes wrong, just `_rfc` and then `_rlc`

        cat "$1" >> "$MY_SH/cache.bash"

        # append a new line for preventing issue
        echo -e "\n" >> "$MY_SH/cache.bash"
    else
        if [[ "$(cat "$1" | grep 'export PATH')" != '' ]];then
            echo "$(cat "$1" | grep 'export PATH')" >> "$MY_SH/cache.bash"
        fi<commit_msg>fix: remove use of `grep`<commit_after>#! /usr/bin/env bash
export MY_BIN="$HOME/bin" # 1. executable 2. does not concerns privacy

export MY_DOTFILES="$HOME/.dotfiles"
export MY_BUNDLED_BIN="$MY_DOTFILES/bin" # 1. executable/does not concerns privacy 2. built-in of this whole setup
export MY_SH="$MY_DOTFILES/sh"
export MY_RUNTIME="$MY_SH/runtime"
export MY_SH_MODULE="$MY_SH/module"

export MY_DOTFILES_RESOURCES="$HOME/.dotfiles_resources"
export MY_PRIVATE_BIN="$MY_DOTFILES_RESOURCES/bin" # 1. executable 2. concerns privacy 3. will be deleted in cleanup-process.

if [[ ! -d "$MY_BIN" ]];then
    mkdir -p "$MY_BIN"
fi

if [[ ! -d "$MY_DOTFILES_RESOURCES" ]];then
    mkdir -p "$MY_DOTFILES_RESOURCES"
fi

if [[ ! -d "$MY_PRIVATE_BIN" ]];then
    mkdir -p "$MY_PRIVATE_BIN"
fi

# reset to avoid issue causing by repeat sourcing
unset PATH
export PATH="/usr/bin:/bin:/usr/sbin:/sbin"
export PATH="$MY_BUNDLED_BIN:$PATH"
export PATH="$MY_PRIVATE_BIN:$PATH"

unset PROMPT_COMMAND

# for internal function, no `Usage`, only print log
_sh_log() {
    if [[ "$#" == 2 ]];then
        local LOG_DIR="$MY_DOTFILES/log"
        if [[ -d "$LOG_DIR" ]]; then
            echo "$(date +%Y-%m-%d-%H-%M-%S) [$1] : $2" >> $LOG_DIR/sh.log
        fi
    fi
}

_cache_gen() {
    # generate cache.bash
    if [[ ! "$1" =~ 'init' ]];then
        # echo '[[ -r '"$file"' ]] && [[ -f '"$file"' ]] && source '"$1" >> "$MY_SH/cache.bash"
        # cut overhead as much as possible, so no checking for existence of each file, if anything goes wrong, just `_rfc` and then `_rlc`

        cat "$1" >> "$MY_SH/cache.bash"

        # append a new line to prevent issue
        echo -e "\n" >> "$MY_SH/cache.bash"
    else
        while IFS= read -r line
        do
            [[ "$line" =~ 'export PATH' ]] && echo "$line" >> "$MY_SH/cache.bash"
        done < <(cat "$1")
{'fraction_non_alphanumeric': 0.1692840031940378, 'fraction_numerical': 0.0077189246739419745, 'mean_word_length': 3.236753100338219, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, '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': '1245580', 'n_tokens_mistral': 1454, 'n_tokens_neox': 1354, 'n_words': 379}