mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2024-11-25 15:35:38 +00:00
Add comment and blank line handling to reference-file-reading functions
This commit is contained in:
parent
88893a3c1b
commit
2e44842458
|
@ -158,10 +158,12 @@ check_for_version_update() {
|
||||||
validate_input() {
|
validate_input() {
|
||||||
while IFS="^" read -r input action || [[ -n "$input" ]];
|
while IFS="^" read -r input action || [[ -n "$input" ]];
|
||||||
do
|
do
|
||||||
|
if [[ ! $input == "#"* ]] && [[ ! -z "$input" ]]; then
|
||||||
if [[ "$input" == "$1" ]]; then
|
if [[ "$input" == "$1" ]]; then
|
||||||
eval "$action"
|
eval "$action"
|
||||||
input_validated="true"
|
input_validated="true"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
done < $input_validation
|
done < $input_validation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ check_bios_files() {
|
||||||
|
|
||||||
while IFS="^" read -r bios_file bios_subdir bios_hash bios_system bios_desc || [[ -n "$bios_file" ]];
|
while IFS="^" read -r bios_file bios_subdir bios_hash bios_system bios_desc || [[ -n "$bios_file" ]];
|
||||||
do
|
do
|
||||||
|
if [[ ! $bios_file == "#"* ]] && [[ ! -z "$bios_file" ]]; then
|
||||||
bios_file_found="No"
|
bios_file_found="No"
|
||||||
bios_hash_matched="No"
|
bios_hash_matched="No"
|
||||||
if [[ -f "$bios_folder/$bios_subdir$bios_file" ]]; then
|
if [[ -f "$bios_folder/$bios_subdir$bios_file" ]]; then
|
||||||
|
@ -29,6 +30,7 @@ check_bios_files() {
|
||||||
bios_checked_list=("${bios_checked_list[@]}" "$bios_file" "$bios_system" "$bios_file_found" "$bios_hash_matched" "$bios_desc" "$bios_subdir" "$bios_hash")
|
bios_checked_list=("${bios_checked_list[@]}" "$bios_file" "$bios_system" "$bios_file_found" "$bios_hash_matched" "$bios_desc" "$bios_subdir" "$bios_hash")
|
||||||
echo "$bios_file"^"$bios_system"^"$bios_file_found"^"$bios_hash_matched"^"$bios_desc"^"$bios_subdir"^"$bios_hash" >> "$godot_bios_files_checked" # Godot data transfer temp file
|
echo "$bios_file"^"$bios_system"^"$bios_file_found"^"$bios_hash_matched"^"$bios_desc"^"$bios_subdir"^"$bios_hash" >> "$godot_bios_files_checked" # Godot data transfer temp file
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
done < $bios_checklist
|
done < $bios_checklist
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -412,7 +412,7 @@ 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 || [[ -n "$action" ]];
|
while IFS="^" read -r action current_section setting_name setting_value system_name || [[ -n "$action" ]];
|
||||||
do
|
do
|
||||||
|
if [[ ! $action == "#"* ]] && [[ ! -z "$action" ]]; then
|
||||||
case $action in
|
case $action in
|
||||||
|
|
||||||
"disable_file" )
|
"disable_file" )
|
||||||
|
@ -442,15 +442,12 @@ do
|
||||||
set_setting_value "$3" "$setting_name" "$setting_value" "$system_name" "$current_section"
|
set_setting_value "$3" "$setting_name" "$setting_value" "$system_name" "$current_section"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*"#"* )
|
|
||||||
# Comment line in patch file
|
|
||||||
;;
|
|
||||||
|
|
||||||
* )
|
* )
|
||||||
echo "Config line malformed: $action"
|
log e "Config line malformed: $action"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
fi
|
||||||
done < "$2"
|
done < "$2"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,6 +460,7 @@ deploy_multi_patch() {
|
||||||
|
|
||||||
while IFS="^" read -r action current_section setting_name setting_value system_name config_file || [[ -n "$action" ]];
|
while IFS="^" read -r action current_section setting_name setting_value system_name config_file || [[ -n "$action" ]];
|
||||||
do
|
do
|
||||||
|
if [[ ! $action == "#"* ]] && [[ ! -z "$action" ]]; then
|
||||||
case $action in
|
case $action in
|
||||||
|
|
||||||
"disable_file" )
|
"disable_file" )
|
||||||
|
@ -507,14 +505,11 @@ do
|
||||||
set_setting_value "$config_file" "$setting_name" "$setting_value" "$system_name" "$current_section"
|
set_setting_value "$config_file" "$setting_name" "$setting_value" "$system_name" "$current_section"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*"#"* )
|
|
||||||
# Comment line in patch file
|
|
||||||
;;
|
|
||||||
|
|
||||||
* )
|
* )
|
||||||
echo "Config line malformed: $action"
|
log e "Config line malformed: $action"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
fi
|
||||||
done < "$1"
|
done < "$1"
|
||||||
}
|
}
|
||||||
|
|
|
@ -363,7 +363,9 @@ finit_user_options_dialog() {
|
||||||
|
|
||||||
while IFS="^" read -r enabled option_name option_desc option_tag || [[ -n "$enabled" ]];
|
while IFS="^" read -r enabled option_name option_desc option_tag || [[ -n "$enabled" ]];
|
||||||
do
|
do
|
||||||
|
if [[ ! $enabled == "#"* ]] && [[ ! -z "$enabled" ]]; then
|
||||||
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")
|
||||||
|
fi
|
||||||
done < $finit_options_list
|
done < $finit_options_list
|
||||||
|
|
||||||
|
|
||||||
|
@ -581,12 +583,14 @@ easter_eggs() {
|
||||||
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 || [[ -n "$start_date" ]]; # 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 [[ ! $start_date == "#"* ]] && [[ ! -z "$start_date" ]]; then
|
||||||
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"
|
||||||
break
|
break
|
||||||
else # When there are no matches, the default splash screen is set to deploy
|
else # When there are no matches, the default splash screen is set to deploy
|
||||||
new_splash_file="$default_splash_file"
|
new_splash_file="$default_splash_file"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
done < $easter_egg_checklist
|
done < $easter_egg_checklist
|
||||||
else
|
else
|
||||||
new_splash_file="$default_splash_file"
|
new_splash_file="$default_splash_file"
|
||||||
|
|
|
@ -79,13 +79,16 @@ make_preset_changes() {
|
||||||
fi
|
fi
|
||||||
set_setting_value "$rd_conf" "$emulator" "true" "retrodeck" "$preset"
|
set_setting_value "$rd_conf" "$emulator" "true" "retrodeck" "$preset"
|
||||||
# Check for conflicting presets for this system
|
# Check for conflicting presets for this system
|
||||||
while IFS=: read -r preset_being_checked known_incompatible_preset; do
|
while IFS=: read -r preset_being_checked known_incompatible_preset || [[ -n "$preset_being_checked" ]];
|
||||||
|
do
|
||||||
|
if [[ ! $preset_being_checked == "#"* ]] && [[ ! -z "$preset_being_checked" ]]; then
|
||||||
if [[ "$preset" == "$preset_being_checked" ]]; then
|
if [[ "$preset" == "$preset_being_checked" ]]; then
|
||||||
if [[ $(get_setting_value "$rd_conf" "$emulator" "retrodeck" "$known_incompatible_preset") == "true" ]]; then
|
if [[ $(get_setting_value "$rd_conf" "$emulator" "retrodeck" "$known_incompatible_preset") == "true" ]]; then
|
||||||
changed_presets=("${changed_presets[@]}" "$known_incompatible_preset")
|
changed_presets=("${changed_presets[@]}" "$known_incompatible_preset")
|
||||||
set_setting_value "$rd_conf" "$emulator" "false" "retrodeck" "$known_incompatible_preset"
|
set_setting_value "$rd_conf" "$emulator" "false" "retrodeck" "$known_incompatible_preset"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
done < "$incompatible_presets_reference_list"
|
done < "$incompatible_presets_reference_list"
|
||||||
fi
|
fi
|
||||||
if [[ ! " ${choices[*]} " =~ " ${emulator} " && ! " ${current_disabled_systems[*]} " =~ " ${emulator} " ]]; then
|
if [[ ! " ${choices[*]} " =~ " ${emulator} " && ! " ${current_disabled_systems[*]} " =~ " ${emulator} " ]]; then
|
||||||
|
@ -118,6 +121,7 @@ build_preset_config() {
|
||||||
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 || [[ -n "$action" ]];
|
while IFS='^' read -r action read_preset read_setting_name new_setting_value section target_file defaults_file || [[ -n "$action" ]];
|
||||||
do
|
do
|
||||||
|
if [[ ! $action == "#"* ]] && [[ ! -z "$action" ]]; then
|
||||||
case "$action" in
|
case "$action" in
|
||||||
|
|
||||||
"config_file_format" )
|
"config_file_format" )
|
||||||
|
@ -191,6 +195,7 @@ build_preset_config() {
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
fi
|
||||||
done < <(cat "$presets_dir/$read_system_name"_presets.cfg)
|
done < <(cat "$presets_dir/$read_system_name"_presets.cfg)
|
||||||
fi
|
fi
|
||||||
done < <(printf '%s\n' "$preset_section")
|
done < <(printf '%s\n' "$preset_section")
|
||||||
|
|
Loading…
Reference in a new issue