From 89584bb0561cef5e379aa4ea402f30948aead783 Mon Sep 17 00:00:00 2001 From: icenine451 Date: Tue, 16 May 2023 14:44:35 -0400 Subject: [PATCH] Fixed presets engine handling paths with spaces --- .../retrodeck/presets/genesis_presets.cfg | 2 +- functions/patching.sh | 20 +++++++++---------- functions/presets.sh | 8 ++++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/emu-configs/defaults/retrodeck/presets/genesis_presets.cfg b/emu-configs/defaults/retrodeck/presets/genesis_presets.cfg index 5abe0756..ef0fbc5b 100644 --- a/emu-configs/defaults/retrodeck/presets/genesis_presets.cfg +++ b/emu-configs/defaults/retrodeck/presets/genesis_presets.cfg @@ -1,7 +1,7 @@ config_file_format^retroarch target_file^/var/config/retroarch/config/Genesis Plus GX/genesis.cfg defaults_file^$emuconfigs/retroarch/retroarch.cfg -change^borders^input_overlay^input_overlay^/var/config/retroarch/overlays/borders/pegasus/genesis.cfg +change^borders^input_overlay^/var/config/retroarch/overlays/borders/pegasus/genesis.cfg change^borders^input_overlay_aspect_adjust_landscape^0.100000 change^borders^input_overlay_enable^true change^borders^input_overlay_scale_landscape^1.040000 diff --git a/functions/patching.sh b/functions/patching.sh index 928728c5..8a40059c 100644 --- a/functions/patching.sh +++ b/functions/patching.sh @@ -151,12 +151,12 @@ add_setting_line() { * ) if [[ -z $current_section_name ]]; then if [[ -f "$1" ]]; then - sed -i '$ a '"$current_setting_line"'' $1 + sed -i '$ a '"$current_setting_line"'' "$1" else # If the file doesn't exist, sed add doesn't work for the first line echo "$current_setting_line" > $1 fi else - sed -i '/^\s*?\['"$current_section_name"'\]|\b'"$current_section_name"':$/a '"$current_setting_line"'' $1 + sed -i '/^\s*?\['"$current_section_name"'\]|\b'"$current_section_name"':$/a '"$current_setting_line"'' "$1" fi ;; @@ -175,9 +175,9 @@ add_setting() { "retroarch" ) if [[ -z $current_section_name ]]; then - sed -i '$ a '"$current_setting_name"' = "'"$current_setting_value"'"' $1 + sed -i '$ a '"$current_setting_name"' = "'"$current_setting_value"'"' "$1" else - sed -i '/^\s*?\['"$current_section_name"'\]|\b'"$current_section_name"':$/a '"$current_setting_name"' = "'"$current_setting_value"'"' $1 + sed -i '/^\s*?\['"$current_section_name"'\]|\b'"$current_section_name"':$/a '"$current_setting_name"' = "'"$current_setting_value"'"' "$1" fi ;; @@ -214,9 +214,9 @@ disable_setting() { * ) if [[ -z $current_section_name ]]; then - sed -i -E 's^(\s*?)'"$current_setting_line"'^\1#'"$current_setting_line"'^' $1 + sed -i -E 's^(\s*?)'"$current_setting_line"'^\1#'"$current_setting_line"'^' "$1" else - sed -i -E '\^\['"$current_section_name"'\]|\b'"$current_section_name"':$^,\^\s*?'"$current_setting_line"'^s^(\s*?)'"$current_setting_line"'^\1#'"$current_setting_line"'^' $1 + sed -i -E '\^\['"$current_section_name"'\]|\b'"$current_section_name"':$^,\^\s*?'"$current_setting_line"'^s^(\s*?)'"$current_setting_line"'^\1#'"$current_setting_line"'^' "$1" fi ;; @@ -234,9 +234,9 @@ enable_setting() { * ) if [[ -z $current_section_name ]]; then - sed -i -E 's^(\s*?)#'"$current_setting_line"'^\1'"$current_setting_line"'^' $1 + sed -i -E 's^(\s*?)#'"$current_setting_line"'^\1'"$current_setting_line"'^' "$1" else - sed -i -E '\^\['"$current_section_name"'\]|\b'"$current_section_name"':$^,\^\s*?#'"$current_setting_line"'^s^(\s*?)#'"$current_setting_line"'^\1'"$current_setting_line"'^' $1 + sed -i -E '\^\['"$current_section_name"'\]|\b'"$current_section_name"':$^,\^\s*?#'"$current_setting_line"'^s^(\s*?)#'"$current_setting_line"'^\1'"$current_setting_line"'^' "$1" fi ;; @@ -248,7 +248,7 @@ disable_file() { # USAGE: disable_file $file_name # NOTE: $filename can be a defined variable from global.sh or must have the full path to the file - mv $(realpath $1) $(realpath $1).disabled + mv "$(realpath "$1")" "$(realpath "$1")".disabled } enable_file() { @@ -256,7 +256,7 @@ enable_file() { # USAGE: enable_file $file_name # NOTE: $filename can be a defined variable from global.sh or must have the full path to the file and should not have ".disabled" as a suffix - mv $(realpath $1.disabled) $(realpath $(echo $1 | sed -e 's/\.disabled//')) + mv "$(realpath "$1".disabled)" "$(realpath "$(echo "$1" | sed -e 's/\.disabled//')")" } generate_single_patch() { diff --git a/functions/presets.sh b/functions/presets.sh index b1ccfc26..951e5659 100644 --- a/functions/presets.sh +++ b/functions/presets.sh @@ -121,8 +121,8 @@ build_preset_config() { if [[ "$read_config_format" == "retroarch" ]]; then # If this is a RetroArch core, generate the override file if [[ -z $(grep "$read_setting_name" "$read_target_file") ]]; then if [[ ! -f "$read_target_file" ]]; then - mkdir -p "$(realpath $(dirname "$read_target_file"))" - echo "$read_setting_name = ""$new_setting_value""" > "$read_target_file" + mkdir -p "$(realpath "$(dirname "$read_target_file")")" + echo "$read_setting_name = \""$new_setting_value"\"" > "$read_target_file" else add_setting "$read_target_file" "$read_setting_name" "$new_setting_value" "$read_config_format" "$section" fi @@ -142,8 +142,8 @@ build_preset_config() { if [[ -z $(cat "$read_target_file") ]]; then # If the override file is empty rm -f "$read_target_file" fi - if [[ -z $(ls -1 $(dirname "$read_target_file")) ]]; then # If the override folder is empty - rmdir "$(dirname $read_target_file)" + if [[ -z $(ls -1 "$(dirname "$read_target_file")") ]]; then # If the override folder is empty + rmdir "$(realpath "$(dirname "$read_target_file")")" fi fi else