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

write_error_message()
{
	message="${1}"
	if [[ -z $message ]]; then
		message="No message specified for output."
	fi
	
	printf "${message}" >&2
}

command_exists()
{
	selected_command=$1
	hash $selected_command 2> /dev/null || { write_error_message "The ${selected_command} does not exist."; return 1; }
	return 0
}

type_exists()
{
	selected_type=$1
	type $selected_command > /dev/null 2>&1 || { write_error_message "The ${selected_type} does not exist."; return 1; }
	return 0
}

detected_package_manager="apt-get"

if [[ command_exists "git" -ne 0 ]]; then
	echo "sudo $detected_package_manager install git"
fi

echo "finished sucessfully!"<commit_msg>Added confirmations to package installation.<commit_after>#!/usr/bin/env bash

write_error_message() {
        message="${1}"
        if [[ -z $message ]]; then
                message="No message specified for output."
        fi

        printf "${message}\n" >&2
}

command_exists() {
        selected_command=$1
        hash $selected_command 2> /dev/null || { write_error_message "The ${selected_command} command does not exist."; return 1; }
        return 0
}

type_exists() {
        selected_type=$1
        type $selected_command > /dev/null 2>&1 || { write_error_message "The ${selected_type} keyword/type does not exist."; return 1; }
        return 0
}

display_confirmation_prompt() {
        prompt_message="$1"
        if [[ -z $prompt_message ]]; then
                prompt_message="Is this okay?"
        fi

        read -r -p "$prompt_message" user_response
        case $user_response in
                [yY][eE][sS]|[yY])
                        return 0
                        ;;
                *)
                        return 1
                        ;;
        esac
}

install_package() {
        package_name="$1"
        if [[ -z $package_name ]]; then
                write_error_message "A package name for installation must be specified."
                return 1
        fi

        [[ $package_name =~ [A-Za-z0-9] ]]
        if [[ $? -eq 0 ]]; then
                display_confirmation_prompt "Would you like to install [${package_name}]?"
                if [[ $? -ne 0 ]]; then
                        return 1
                fi

                write_error_message "Preparing to install [$package_name]."
                echo "sudo $detected_package_manager install $package_name"
        else
                write_error_message "The package name contains invalid characters. Package name: [${package_name}]"
        fi


}

detected_package_manager="apt-get"

command_exists "git"
if [[ $? -ne 0 ]]; then
        install_package "git"
fi

echo "finished sucessfully!"
{'fraction_non_alphanumeric': 0.11769059955588453, 'fraction_numerical': 0.012583271650629163, 'mean_word_length': 2.1762632197414806, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '3464849', 'n_tokens_mistral': 839, 'n_tokens_neox': 777, 'n_words': 216}