From 88893a3c1b185944692dc4cd79447b49fa5e0848 Mon Sep 17 00:00:00 2001 From: icenine451 Date: Sat, 29 Jun 2024 15:17:08 -0400 Subject: [PATCH] Add compensation for reading reference files where there is not an empty newline at the end of the file --- automation_tools/pre_build_automation.sh | 2 +- functions/checks.sh | 2 +- functions/configurator_functions.sh | 4 ++-- functions/framework.sh | 4 ++-- functions/other_functions.sh | 6 +++--- functions/presets.sh | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/automation_tools/pre_build_automation.sh b/automation_tools/pre_build_automation.sh index 476ae315..5d9a7c91 100755 --- a/automation_tools/pre_build_automation.sh +++ b/automation_tools/pre_build_automation.sh @@ -50,7 +50,7 @@ cat "$automation_task_list" echo # Update all collected information -while IFS="^" read -r action placeholder url branch +while IFS="^" read -r action placeholder url branch || [[ -n "$action" ]]; do if [[ ! $action == "#"* ]] && [[ ! -z "$action" ]]; then case "$action" in diff --git a/functions/checks.sh b/functions/checks.sh index 713556aa..a1589f22 100644 --- a/functions/checks.sh +++ b/functions/checks.sh @@ -156,7 +156,7 @@ check_for_version_update() { } validate_input() { - while IFS="^" read -r input action + while IFS="^" read -r input action || [[ -n "$input" ]]; do if [[ "$input" == "$1" ]]; then eval "$action" diff --git a/functions/configurator_functions.sh b/functions/configurator_functions.sh index 7e3a0870..11ce5eb0 100644 --- a/functions/configurator_functions.sh +++ b/functions/configurator_functions.sh @@ -10,7 +10,7 @@ check_bios_files() { fi touch "$godot_bios_files_checked" - while IFS="^" read -r bios_file bios_subdir bios_hash bios_system bios_desc + while IFS="^" read -r bios_file bios_subdir bios_hash bios_system bios_desc || [[ -n "$bios_file" ]]; do bios_file_found="No" bios_hash_matched="No" @@ -44,7 +44,7 @@ find_empty_rom_folders() { all_empty_folders=() all_helper_files=() - while IFS='^' read -r file dest + while IFS='^' read -r file dest || [[ -n "$file" ]]; do if [[ ! "$file" == "#"* ]] && [[ ! -z "$file" ]]; then all_helper_files=("${all_helper_files[@]}" "$file") diff --git a/functions/framework.sh b/functions/framework.sh index 92f3b32e..d64fd16e 100644 --- a/functions/framework.sh +++ b/functions/framework.sh @@ -410,7 +410,7 @@ deploy_single_patch() { cp -fv "$1" "$3" # Create a copy of the original file to be patched -while IFS="^" read -r action current_section setting_name setting_value system_name +while IFS="^" read -r action current_section setting_name setting_value system_name || [[ -n "$action" ]]; do case $action in @@ -461,7 +461,7 @@ deploy_multi_patch() { # Patch file format should be as follows, with optional entries in (). Optional settings can be left empty, but must still have ^ dividers: # $action^($current_section)^$setting_name^$setting_value^$system_name^($config file) -while IFS="^" read -r action current_section setting_name setting_value system_name config_file +while IFS="^" read -r action current_section setting_name setting_value system_name config_file || [[ -n "$action" ]]; do case $action in diff --git a/functions/other_functions.sh b/functions/other_functions.sh index 90faa7fc..7e5d3c40 100644 --- a/functions/other_functions.sh +++ b/functions/other_functions.sh @@ -361,7 +361,7 @@ done finit_user_options_dialog() { finit_available_options=() - while IFS="^" read -r enabled option_name option_desc option_tag + while IFS="^" read -r enabled option_name option_desc option_tag || [[ -n "$enabled" ]]; do finit_available_options=("${finit_available_options[@]}" "$enabled" "$option_name" "$option_desc" "$option_tag") done < $finit_options_list @@ -561,7 +561,7 @@ deploy_helper_files() { # This script will distribute helper documentation files throughout the filesystem according to the $helper_files_list # USAGE: deploy_helper_files - while IFS='^' read -r file dest + while IFS='^' read -r file dest || [[ -n "$file" ]]; do if [[ ! "$file" == "#"* ]] && [[ ! -z "$file" ]]; then eval current_dest="$dest" @@ -579,7 +579,7 @@ easter_eggs() { current_day=$(date +"%0m%0d") # Read the current date in a format that can be calculated in ranges current_time=$(date +"%0H%0M") # Read the current time in a format that can be calculated in ranges if [[ ! -z $(cat $easter_egg_checklist) ]]; then - while IFS="^" read -r start_date end_date start_time end_time splash_file # Read Easter Egg checklist file and separate values + while IFS="^" read -r start_date end_date start_time end_time splash_file || [[ -n "$start_date" ]]; # Read Easter Egg checklist file and separate values do if [[ "$((10#$current_day))" -ge "$((10#$start_date))" && "$((10#$current_day))" -le "$((10#$end_date))" && "$((10#$current_time))" -ge "$((10#$start_time))" && "$((10#$current_time))" -le "$((10#$end_time))" ]]; then # If current line specified date/time matches current date/time, set $splash_file to be deployed new_splash_file="$splashscreen_dir/$splash_file" diff --git a/functions/presets.sh b/functions/presets.sh index c7d4ff66..b3abaf4e 100644 --- a/functions/presets.sh +++ b/functions/presets.sh @@ -116,7 +116,7 @@ build_preset_config() { local read_system_name=$(get_setting_name "$system_line") if [[ "$read_system_name" == "$system_being_changed" ]]; then local read_system_enabled=$(get_setting_value "$rd_conf" "$read_system_name" "retrodeck" "$current_preset") - while IFS='^' read -r action read_preset read_setting_name new_setting_value section target_file defaults_file + while IFS='^' read -r action read_preset read_setting_name new_setting_value section target_file defaults_file || [[ -n "$action" ]]; do case "$action" in @@ -202,7 +202,7 @@ build_retrodeck_current_presets() { # This can also be used to build the "current" state post-update after adding new systems # USAGE: build_retrodeck_current_presets - while IFS= read -r current_setting_line # Read the existing retrodeck.cfg + while IFS= read -r current_setting_line || [[ -n "$current_setting_line" ]]; # Read the existing retrodeck.cfg do if [[ (! -z "$current_setting_line") && (! "$current_setting_line" == "#"*) && (! "$current_setting_line" == "[]") ]]; then # If the line has a valid entry in it if [[ ! -z $(grep -o -P "^\[.+?\]$" <<< "$current_setting_line") ]]; then # If the line is a section header