Changeset - 73da88ad939e
[Not reviewed]
0 1 0
Branko Majic (branko) - 4 years ago 2020-07-06 15:58:56
branko@majic.rs
Noticket: [factorio_manager.sh] Use read -r to avoid interpreting backslashes as escape characters.
1 file changed with 6 insertions and 6 deletions:
0 comments (0 inline, 0 general) First comment
games/factorio_manager.sh
Show inline comments
 
@@ -433,13 +433,13 @@ function colorprintf() {
 
function critical_confirmation() {
 
    local prompt_text="$1"
 
    local abort_text="$2"
 
    local exit_code="$3"
 

	
 
    echo -n "${_text_bold}${_text_yellow}[WARN] ${_text_reset}" "${prompt_text} Type YES to confirm (default is no): "
 
    read confirm
 
    read -r confirm
 

	
 
    if [[ $confirm != "YES" ]]; then
 
        error "$abort_text"
 
        exit "$ERROR_GENERAL"
 
    fi
 
}
 
@@ -793,13 +793,13 @@ function read_server_settings() {
 
        done
 

	
 
        # Prompt user to confirm settings.
 
        while [[ ${confirmed,,} != 'y' && ${confirmed,,} != 'n' ]]; do
 
            echo
 
            colorecho -n "green" "Are you satisfied with current settings (y/n)? "
 
            read -n1 confirmed
 
            read -rn1 confirmed
 
            echo
 
        done
 

	
 
        # Allow user to provide changed values if not satisfied with
 
        # settings.
 
        if [[ ${confirmed,,} == 'n' ]]; then
 
@@ -830,13 +830,13 @@ function read_server_settings() {
 
                colorecho "white" "${settings_description[$key]}" | fold -s
 

	
 
                # Keep prompting user until a valid value is provided.
 
                validation_result=""
 
                until [[ $validation_result == 0 ]]; do
 

	
 
                    read -p "$prompt" -e -i "${settings_value[$key]}" value
 
                    read -r -p "$prompt" -e -i "${settings_value[$key]}" value
 

	
 
                    validate_server_setting_value "${settings_prompt[$key]}" "$value" "${settings_type[$key]}"
 
                    validation_result="$?"
 
                    [[ $validation_result == 2 ]] && error "Internal error, type not set correctly for setting: $key." && exit "$ERROR_GENERAL"
 
                done
 

	
 
@@ -1069,13 +1069,13 @@ function select_factorio_version() {
 
        fi
 
    done
 

	
 
    echo
 

	
 
    while [[ -z $game_version_selected ]]; do
 
        read -e -p "Please specify what version you would like to use (enter for $default_marker): " selected_option
 
        read -r -e -p "Please specify what version you would like to use (enter for $default_marker): " selected_option
 
        [[ -z $selected_option ]] && selected_option="$default_option"
 

	
 
        if [[ $selected_option =~ ^[[:digit:]]+$ ]] && (( $selected_option >= 1 && $selected_option <= ${#game_versions_available[@]} )); then
 
            game_version_selected="${game_versions_available[$selected_option-1]}"
 
        else
 
            error "Invalid option selected, please try again."
 
@@ -2054,13 +2054,13 @@ elif [[ $command == copy ]]; then
 

	
 
        # Check if user wants to copy backup files as well.
 
        copy_backups=""
 

	
 
        until [[ $copy_backups == "y" || $copy_backups == "n" ]]; do
 
            echo
 
            read -n1 -p "Would you like to copy backup files as well? (y/n)" copy_backups
 
            read -rn1 -p "Would you like to copy backup files as well? (y/n)" copy_backups
 
            echo
 
            copy_backups="${copy_backups,,}"
 

	
 
            if [[ $copy_backups != "y" && $copy_backups != "n" ]]; then
 
                echo
 
                error "Please answer only with 'y' or 'n'."
 
@@ -2194,13 +2194,13 @@ EOF
 
            echo
 
            for missing_import_entry in "${missing_import_entries[@]}"; do
 
                echo "$(colorecho blue "$missing_import_entry"), ${import_entries[$missing_import_entry]}"
 
                echo
 
            done
 
            warning "Press any key to continue."
 
            read -n1
 
            read -rn1
 
        fi
 

	
 
        success "Finished import of instance $(colorecho -n green "$instance")."
 

	
 
    ) 200>"$source_lock_file"
 

	
0 comments (0 inline, 0 general) First comment
You need to be logged in to comment. Login now