Fix bug in patch engine for settings with names

that contain the names of other settings
ie. "setting=value" and "other_setting=value"
This commit is contained in:
icenine451 2023-03-16 16:12:04 -04:00
parent 1290966409
commit 29e6f8eb6d

View file

@ -247,38 +247,38 @@ set_setting_value() {
"retrodeck" | "citra" | "melonds" | "yuzu" ) "retrodeck" | "citra" | "melonds" | "yuzu" )
if [[ -z $current_section_name ]]; then if [[ -z $current_section_name ]]; then
sed -i 's^'"$setting_name_to_change"'=.*^'"$setting_name_to_change"'='"$setting_value_to_change"'^' $1 sed -i 's^\^'"$setting_name_to_change"'=.*^'"$setting_name_to_change"'='"$setting_value_to_change"'^' $1
else else
sed -i '\^\['"$current_section_name"'\]^,\^'"$setting_name_to_change"'.*^s^'"$setting_name_to_change"'=.*^'"$setting_name_to_change"'='"$setting_value_to_change"'^' $1 sed -i '\^\['"$current_section_name"'\]^,\^\^'"$setting_name_to_change"'.*^s^\^'"$setting_name_to_change"'=.*^'"$setting_name_to_change"'='"$setting_value_to_change"'^' $1
fi fi
;; ;;
"retroarch" ) "retroarch" )
if [[ -z $current_section_name ]]; then if [[ -z $current_section_name ]]; then
sed -i 's^'"$setting_name_to_change"' = \".*\"^'"$setting_name_to_change"' = \"'"$setting_value_to_change"'\"^' $1 sed -i 's^\^'"$setting_name_to_change"' = \".*\"^'"$setting_name_to_change"' = \"'"$setting_value_to_change"'\"^' $1
else else
sed -i '\^\['"$current_section_name"'\]^,\^'"$setting_name_to_change"'.*^s^'"$setting_name_to_change"' = \".*\"^'"$setting_name_to_change"' = \"'"$setting_value_to_change"'\"^' $1 sed -i '\^\['"$current_section_name"'\]^,\^\^'"$setting_name_to_change"'.*^s^\^'"$setting_name_to_change"' = \".*\"^'"$setting_name_to_change"' = \"'"$setting_value_to_change"'\"^' $1
fi fi
;; ;;
"dolphin" | "duckstation" | "pcsx2" | "ppsspp" | "primehack" | "xemu" ) "dolphin" | "duckstation" | "pcsx2" | "ppsspp" | "primehack" | "xemu" )
if [[ -z $current_section_name ]]; then if [[ -z $current_section_name ]]; then
sed -i 's^'"$setting_name_to_change"' =.*^'"$setting_name_to_change"' = '"$setting_value_to_change"'^' $1 sed -i 's^\^'"$setting_name_to_change"' =.*^'"$setting_name_to_change"' = '"$setting_value_to_change"'^' $1
else else
sed -i '\^\['"$current_section_name"'\]^,\^'"$setting_name_to_change"'.*^s^'"$setting_name_to_change"' =.*^'"$setting_name_to_change"' = '"$setting_value_to_change"'^' $1 sed -i '\^\['"$current_section_name"'\]^,\^\^'"$setting_name_to_change"'.*^s^\^'"$setting_name_to_change"' =.*^'"$setting_name_to_change"' = '"$setting_value_to_change"'^' $1
fi fi
;; ;;
"rpcs3" ) # This does not currently work for settings with a $ in them "rpcs3" ) # This does not currently work for settings with a $ in them
if [[ -z $current_section_name ]]; then if [[ -z $current_section_name ]]; then
sed -i 's^'"$setting_name_to_change"': .*^'"$setting_name_to_change"': '"$setting_value_to_change"'^' $1 sed -i 's^\^'"$setting_name_to_change"': .*^'"$setting_name_to_change"': '"$setting_value_to_change"'^' $1
else else
sed -i '\^\['"$current_section_name"'\]^,\^'"$setting_name_to_change"'.*^s^'"$setting_name_to_change"': .*^'"$setting_name_to_change"': '"$setting_value_to_change"'^' $1 sed -i '\^\['"$current_section_name"'\]^,\^\^'"$setting_name_to_change"'.*^s^\^'"$setting_name_to_change"': .*^'"$setting_name_to_change"': '"$setting_value_to_change"'^' $1
fi fi
;; ;;
"emulationstation" ) "emulationstation" )
sed -i "s%$setting_name_to_change\" \" value=\".*\"%$setting_name_to_change\" \" value=\"$setting_value_to_change\"" $1 sed -i "s%^$setting_name_to_change\" \" value=\".*\"%$setting_name_to_change\" \" value=\"$setting_value_to_change\"" $1
;; ;;
esac esac
@ -320,7 +320,7 @@ get_setting_value() {
if [[ -z $current_section_name ]]; then if [[ -z $current_section_name ]]; then
echo $(grep -o -P "(?<=^$current_setting_name=).*" $1) echo $(grep -o -P "(?<=^$current_setting_name=).*" $1)
else else
sed -n '\^\['"$current_section_name"'\]^,\^'"$current_setting_name"'^{ \^\['"$current_section_name"'\]^! { \^'"$current_setting_name"'^ p } }' $1 | grep -o -P "(?<=^$current_setting_name=).*" sed -n '\^\['"$current_section_name"'\]^,\^\^'"$current_setting_name"'^{ \^\['"$current_section_name"'\]^! { \^\^'"$current_setting_name"'^ p } }' $1 | grep -o -P "(?<=^$current_setting_name=).*"
fi fi
;; ;;
@ -328,7 +328,7 @@ get_setting_value() {
if [[ -z $current_section_name ]]; then if [[ -z $current_section_name ]]; then
echo $(grep -o -P "(?<=^$current_setting_name = \").*(?=\")" $1) echo $(grep -o -P "(?<=^$current_setting_name = \").*(?=\")" $1)
else else
sed -n '\^\['"$current_section_name"'\]^,\^'"$current_setting_name"'^{ \^\['"$current_section_name"'\]^! { \^'"$current_setting_name"'^ p } }' $1 | grep -o -P "(?<=^$current_setting_name = \").*(?=\")" sed -n '\^\['"$current_section_name"'\]^,\^\^'"$current_setting_name"'^{ \^\['"$current_section_name"'\]^! { \^\^'"$current_setting_name"'^ p } }' $1 | grep -o -P "(?<=^$current_setting_name = \").*(?=\")"
fi fi
;; ;;
@ -336,7 +336,7 @@ get_setting_value() {
if [[ -z $current_section_name ]]; then if [[ -z $current_section_name ]]; then
echo $(grep -o -P "(?<=^$current_setting_name = ).*" $1) echo $(grep -o -P "(?<=^$current_setting_name = ).*" $1)
else else
sed -n '\^\['"$current_section_name"'\]^,\^'"$current_setting_name"'^{ \^\['"$current_section_name"'\]^! { \^'"$current_setting_name"'^ p } }' $1 | grep -o -P "(?<=^$current_setting_name = ).*" sed -n '\^\['"$current_section_name"'\]^,\^\^'"$current_setting_name"'^{ \^\['"$current_section_name"'\]^! { \^\^'"$current_setting_name"'^ p } }' $1 | grep -o -P "(?<=^$current_setting_name = ).*"
fi fi
;; ;;
@ -344,7 +344,7 @@ get_setting_value() {
if [[ -z $current_section_name ]]; then if [[ -z $current_section_name ]]; then
echo $(grep -o -P "(?<=$current_setting_name: ).*" $1) echo $(grep -o -P "(?<=$current_setting_name: ).*" $1)
else else
sed -n '\^\['"$current_section_name"'\]^,\^'"$current_setting_name"'^{ \^\['"$current_section_name"'\]^! { \^'"$current_setting_name"'^ p } }' $1 | grep -o -P "(?<=$current_setting_name: ).*" sed -n '\^\['"$current_section_name"'\]^,\^\^'"$current_setting_name"'^{ \^\['"$current_section_name"'\]^! { \^\^'"$current_setting_name"'^ p } }' $1 | grep -o -P "(?<=$current_setting_name: ).*"
fi fi
;; ;;