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

koopa::install_openjdk() { # {{{1
    # """
    # Install OpenJDK.
    # @note Updated 2020-09-18.
    #
    # Don't early return if directory exists here.
    # We need to ensure alternatives code runs (see below).
    #
    # @seealso
    # - https://jdk.java.net/14/
    # - https://openjdk.java.net/
    # """
    local jdk_dir name name_fancy prefix reinstall tmp_dir unique version
    name='openjdk'
    name_fancy='OpenJDK'
    reinstall=0
    version=
    while (("$#"))
    do
        case "$1" in
            --reinstall)
                reinstall=1
                shift 1
                ;;
            --version=*)
                version="${1#*=}"
                shift 1
                ;;
            *)
                koopa::invalid_arg "$1"
                ;;
        esac
    done
    koopa::assert_has_no_args "$#"
    [[ -z "$version" ]] && version="$(koopa::variable "$name")"
    jdk_dir="$(koopa::openjdk_prefix)"
    prefix="${jdk_dir}/${version}"
    [[ "$reinstall" -eq 1 ]] && koopa::sys_rm "$prefix"
    [[ -d "$prefix" ]] && return 0
    koopa::install_start "$name_fancy" "$version" "$prefix"
    koopa::mkdir "$jdk_dir"
    tmp_dir="$(koopa::tmp_dir)"
    (
        koopa::cd "$tmp_dir"
        case "$version" in
            13)
                unique='5b8a42f3905b406298b72d750b6919f6/33'
                ;;
            13.0.1)
                unique='cec27d702aa74d5a8630c65ae61e4305/9'
                ;;
            13.0.2)
                unique='d4173c853231432d94f001e99d882ca7/8'
                ;;
            14)
                unique='076bab302c7b4508975440c56f6cc26a/36'
                ;;
            14.0.1)
                unique='664493ef4a6946b186ff29eb326336a2/7'
                ;;
            14.0.2)
                unique='205943a0976c4ed48cb16f1043c5c647/12'
                ;;
            15)
                unique='779bf45e88a44cbd9ea6621d33e33db1/36'
                ;;
            *)
                koopa::stop "Unsupported version: '${version}'."
        esac
        file="${name}-${version}_linux-x64_bin.tar.gz"
        url="https://download.java.net/java/GA/jdk${version}/\
${unique}/GPL/${file}"<commit_msg>Improve directory creation<commit_after>#!/usr/bin/env bash

koopa::install_openjdk() { # {{{1
    # """
    # Install OpenJDK.
    # @note Updated 2020-11-10.
    #
    # Don't early return if directory exists here.
    # We need to ensure alternatives code runs (see below).
    #
    # @seealso
    # - https://jdk.java.net/14/
    # - https://openjdk.java.net/
    # """
    local jdk_dir name name_fancy prefix reinstall tmp_dir unique version
    name='openjdk'
    name_fancy='OpenJDK'
    reinstall=0
    version=
    while (("$#"))
    do
        case "$1" in
            --reinstall)
                reinstall=1
                shift 1
                ;;
            --version=*)
                version="${1#*=}"
                shift 1
                ;;
            *)
                koopa::invalid_arg "$1"
                ;;
        esac
    done
    koopa::assert_has_no_args "$#"
    [[ -z "$version" ]] && version="$(koopa::variable "$name")"
    jdk_dir="$(koopa::openjdk_prefix)"
    prefix="${jdk_dir}/${version}"
    [[ "$reinstall" -eq 1 ]] && koopa::sys_rm "$prefix"
    [[ -d "$prefix" ]] && return 0
    koopa::install_start "$name_fancy" "$version" "$prefix"
    koopa::sys_mkdir "$jdk_dir"
    tmp_dir="$(koopa::tmp_dir)"
    (
        koopa::cd "$tmp_dir"
        case "$version" in
            13)
                unique='5b8a42f3905b406298b72d750b6919f6/33'
                ;;
            13.0.1)
                unique='cec27d702aa74d5a8630c65ae61e4305/9'
                ;;
            13.0.2)
                unique='d4173c853231432d94f001e99d882ca7/8'
                ;;
            14)
                unique='076bab302c7b4508975440c56f6cc26a/36'
                ;;
            14.0.1)
                unique='664493ef4a6946b186ff29eb326336a2/7'
                ;;
            14.0.2)
                unique='205943a0976c4ed48cb16f1043c5c647/12'
                ;;
            15)
                unique='779bf45e88a44cbd9ea6621d33e33db1/36'
                ;;
            *)
                koopa::stop "Unsupported version: '${version}'."
        esac
        file="${name}-${version}_linux-x64_bin.tar.gz"
        url="https://download.java.net/java/GA/jdk${version}/\
${unique}/GPL/${file}"
{'fraction_non_alphanumeric': 0.1439820022497188, 'fraction_numerical': 0.09448818897637795, 'mean_word_length': 1.5161290322580645, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7046004', 'n_tokens_mistral': 1799, 'n_tokens_neox': 1485, 'n_words': 217}