Add compensation for reading reference files where there is not an empty newline at the end of the file

This commit is contained in:
icenine451 2024-06-29 15:17:08 -04:00
parent 853d6cf35d
commit 88893a3c1b
6 changed files with 11 additions and 11 deletions

View file

@ -50,7 +50,7 @@ cat "$automation_task_list"
echo echo
# Update all collected information # Update all collected information
while IFS="^" read -r action placeholder url branch while IFS="^" read -r action placeholder url branch || [[ -n "$action" ]];
do do
if [[ ! $action == "#"* ]] && [[ ! -z "$action" ]]; then if [[ ! $action == "#"* ]] && [[ ! -z "$action" ]]; then
case "$action" in case "$action" in

View file

@ -156,7 +156,7 @@ check_for_version_update() {
} }
validate_input() { validate_input() {
while IFS="^" read -r input action while IFS="^" read -r input action || [[ -n "$input" ]];
do do
if [[ "$input" == "$1" ]]; then if [[ "$input" == "$1" ]]; then
eval "$action" eval "$action"

View file

@ -10,7 +10,7 @@ check_bios_files() {
fi fi
touch "$godot_bios_files_checked" 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 do
bios_file_found="No" bios_file_found="No"
bios_hash_matched="No" bios_hash_matched="No"
@ -44,7 +44,7 @@ find_empty_rom_folders() {
all_empty_folders=() all_empty_folders=()
all_helper_files=() all_helper_files=()
while IFS='^' read -r file dest while IFS='^' read -r file dest || [[ -n "$file" ]];
do do
if [[ ! "$file" == "#"* ]] && [[ ! -z "$file" ]]; then if [[ ! "$file" == "#"* ]] && [[ ! -z "$file" ]]; then
all_helper_files=("${all_helper_files[@]}" "$file") all_helper_files=("${all_helper_files[@]}" "$file")

View file

@ -410,7 +410,7 @@ deploy_single_patch() {
cp -fv "$1" "$3" # Create a copy of the original file to be patched 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 do
case $action in 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: # 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) # $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 do
case $action in case $action in

View file

@ -361,7 +361,7 @@ done
finit_user_options_dialog() { finit_user_options_dialog() {
finit_available_options=() 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 do
finit_available_options=("${finit_available_options[@]}" "$enabled" "$option_name" "$option_desc" "$option_tag") finit_available_options=("${finit_available_options[@]}" "$enabled" "$option_name" "$option_desc" "$option_tag")
done < $finit_options_list 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 # This script will distribute helper documentation files throughout the filesystem according to the $helper_files_list
# USAGE: deploy_helper_files # USAGE: deploy_helper_files
while IFS='^' read -r file dest while IFS='^' read -r file dest || [[ -n "$file" ]];
do do
if [[ ! "$file" == "#"* ]] && [[ ! -z "$file" ]]; then if [[ ! "$file" == "#"* ]] && [[ ! -z "$file" ]]; then
eval current_dest="$dest" 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_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 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 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 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 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" new_splash_file="$splashscreen_dir/$splash_file"

View file

@ -116,7 +116,7 @@ build_preset_config() {
local read_system_name=$(get_setting_name "$system_line") local read_system_name=$(get_setting_name "$system_line")
if [[ "$read_system_name" == "$system_being_changed" ]]; then if [[ "$read_system_name" == "$system_being_changed" ]]; then
local read_system_enabled=$(get_setting_value "$rd_conf" "$read_system_name" "retrodeck" "$current_preset") 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 do
case "$action" in 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 # This can also be used to build the "current" state post-update after adding new systems
# USAGE: build_retrodeck_current_presets # 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 do
if [[ (! -z "$current_setting_line") && (! "$current_setting_line" == "#"*) && (! "$current_setting_line" == "[]") ]]; then # If the line has a valid entry in it 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 if [[ ! -z $(grep -o -P "^\[.+?\]$" <<< "$current_setting_line") ]]; then # If the line is a section header