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

# FIXME Need to add patch steps here.



# Variables                                                                 {{{1
# ==============================================================================

name="bash"
version="$(_koopa_variable "$name")"
major_version="$(_koopa_major_version "$version")"
prefix="$(_koopa_cellar_prefix)/${name}/${version}"
tmp_dir="$(_koopa_tmp_dir)/${name}"
build_os_string="$(_koopa_build_os_string)"
gnu_mirror="http://ftpmirror.gnu.org"
exe_file="${prefix}/bin/${name}"



# Usage                                                                     {{{1
# ==============================================================================

usage() {
cat << EOF
$(_koopa_help_header "install-cellar-${name}")

Install Bash.

$(_koopa_help_args)

see also:
    - https://www.gnu.org/software/bash/

note:
    Bash script.
    Updated 2019-10-01.
EOF
}

_koopa_help "$@"



# Script                                                                    {{{1
# ==============================================================================

printf "Installing %s %s.\n" "$name" "$version"

(
    rm -frv "$prefix"
    rm -fr "$tmp_dir"
    mkdir -pv "$tmp_dir"
    cd "$tmp_dir" || exit 1
    wget "${gnu_mirror}/bash/bash-${major_version}.tar.gz"
    tar -xzvf "bash-${major_version}.tar.gz"
    cd "bash-${major_version}" || exit 1
    ./configure \
        --build="$build_os_string" \
        --prefix="$prefix"<commit_msg>Improve bash recipe to apply patches<commit_after>#!/usr/bin/env bash



# Variables                                                                 {{{1
# ==============================================================================

name="bash"
version="$(_koopa_variable "$name")"
major_version="$(_koopa_major_version "$version")"
patches="$(echo "$version" | cut -d '.' -f 3)"
prefix="$(_koopa_cellar_prefix)/${name}/${version}"
tmp_dir="$(_koopa_tmp_dir)/${name}"
build_os_string="$(_koopa_build_os_string)"
gnu_mirror="https://ftpmirror.gnu.org"
exe_file="${prefix}/bin/${name}"




# Usage                                                                     {{{1
# ==============================================================================

usage() {
cat << EOF
$(_koopa_help_header "install-cellar-${name}")

Install Bash.

$(_koopa_help_args)

details:
    Patches (${patches}) are applied automatically.

see also:
    - https://www.gnu.org/software/bash/

note:
    Bash script.
    Updated 2019-10-01.
EOF
}

_koopa_help "$@"



# Script                                                                    {{{1
# ==============================================================================

printf "Installing %s %s.\n" "$name" "$version"

(
    rm -frv "$prefix"
    rm -fr "$tmp_dir"
    mkdir -pv "$tmp_dir"
    cd "$tmp_dir" || exit 1
    wget "${gnu_mirror}/bash/bash-${major_version}.tar.gz"
    tar -xzvf "bash-${major_version}.tar.gz"
    cd "bash-${major_version}" || exit 1
    # Apply patches. Can pipe curl call directly to 'patch -p0' instead.
    (
        mkdir -pv patches
        cd patches || exit 1
        base_url="https://ftp.gnu.org/gnu/bash/bash-${major_version}-patches"
        mv_tr="$(echo "$major_version" | tr -d '.')"
        range="$(printf "%03d-%03d" "1" "$patches")"
        request="${base_url}/bash${mv_tr}-[${range}]"
        curl "$request" -O
        cd .. || exit 1
        for file in patches/*
        do
            patch -p0 --input="$file"
        done
    )
    ./configure \
        --build="$build_os_string" \
        --prefix="$prefix"
{'fraction_non_alphanumeric': 0.2776850306065665, 'fraction_numerical': 0.01001669449081803, 'mean_word_length': 2.417300380228137, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1183725', 'n_tokens_mistral': 1138, 'n_tokens_neox': 1019, 'n_words': 200}