From 73da88ad939e7ca5190fd39d1eb0df6ce4c96f12 2020-07-06 15:58:56
From: Branko Majic <branko@majic.rs>
Date: 2020-07-06 15:58:56
Subject: [PATCH] Noticket: [factorio_manager.sh] Use read -r to avoid interpreting backslashes as escape characters.

---

diff --git a/games/factorio_manager.sh b/games/factorio_manager.sh
index 3fed87f13a1cb4f163e72eff3529cb5d226758f8..92365e61bf8ac0f0b4be422413b7248eeef9b8dc 100755
--- a/games/factorio_manager.sh
+++ b/games/factorio_manager.sh
@@ -436,7 +436,7 @@ function critical_confirmation() {
     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"
@@ -796,7 +796,7 @@ function read_server_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
 
@@ -833,7 +833,7 @@ function read_server_settings() {
                 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="$?"
@@ -1072,7 +1072,7 @@ function select_factorio_version() {
     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
@@ -2057,7 +2057,7 @@ elif [[ $command == copy ]]; then
 
         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,,}"
 
@@ -2197,7 +2197,7 @@ EOF
                 echo
             done
             warning "Press any key to continue."
-            read -n1
+            read -rn1
         fi
 
         success "Finished import of instance $(colorecho -n green "$instance")."