Rewrite edit_db_from_gui

This commit is contained in:
Boria138
2024-01-22 12:40:28 +06:00
parent 4a995f69ae
commit 0d0973794b
2 changed files with 14 additions and 9 deletions

View File

@ -1035,16 +1035,18 @@ update_winetricks () {
edit_db_from_gui () { edit_db_from_gui () {
print_info "edit_db_from_gui PORTWINE_DB_FILE=$PORTWINE_DB_FILE" print_info "edit_db_from_gui PORTWINE_DB_FILE=$PORTWINE_DB_FILE"
for mod_db in $@ ; do for mod_db in "$@" ; do
print_info "${mod_db}=${!mod_db}" print_info "${mod_db}=${!mod_db}"
if [ -z "`cat "${PORTWINE_DB_FILE}" | grep "export ${mod_db}="`" ] ; then escaped_value=$(printf "%s" "${!mod_db}" | sed 's/\\/\\\\/g; s/,/\\,/g')
echo "export ${mod_db}=\"${!mod_db}\"" >> "${PORTWINE_DB_FILE}"
elif [ "`cat "${PORTWINE_DB_FILE}" | grep "export ${mod_db}=" | grep -v "#"`" ] ; then if [ -z "`grep "export ${mod_db}=" "${PORTWINE_DB_FILE}"`" ] ; then
if [ "`cat "${PORTWINE_DB_FILE}" | grep "export ${mod_db}=" | grep -v "#"`" != "export ${mod_db}=\"${!mod_db}\"" ] ; then echo "export ${mod_db}=\"${escaped_value}\"" >> "${PORTWINE_DB_FILE}"
sed -ri "s/^export ${mod_db}=.*/export ${mod_db}=\"${!mod_db}\"/" "${PORTWINE_DB_FILE}" elif [ "`grep "export ${mod_db}=" "${PORTWINE_DB_FILE}" | grep -v "#"`" ] ; then
if [ "`grep "export ${mod_db}=" "${PORTWINE_DB_FILE}" | grep -v "#"`" != "export ${mod_db}=\"${escaped_value}\"" ] ; then
sed -ri "s/^export ${mod_db}=.*/export ${mod_db}=\"${escaped_value}\"/" "${PORTWINE_DB_FILE}"
fi fi
elif [ "`cat "${PORTWINE_DB_FILE}" | grep "export ${mod_db}="`" != "export ${mod_db}=${!mod_db}" ] ; then elif [ "`grep "export ${mod_db}=" "${PORTWINE_DB_FILE}"`" != "export ${mod_db}=${escaped_value}" ] ; then
sed -ri "s/.*export ${mod_db}=.*/export ${mod_db}=\"${!mod_db}\"/g" "${PORTWINE_DB_FILE}" sed -ri "s/.*export ${mod_db}=.*/export ${mod_db}=\"${escaped_value}\"/g" "${PORTWINE_DB_FILE}"
fi fi
done done
return 0 return 0

View File

@ -598,7 +598,10 @@ gui_MangoHud () {
done done
FPS_LIMIT="${FPS_LIMIT}" FPS_LIMIT="${FPS_LIMIT}"
export PW_FPS_LIMIT="0\,${FPS_LIMIT%\\,}" if [ "$(echo "${FPS_LIMIT}" | awk -F',' '{print $2}')" ]
then export PW_FPS_LIMIT="0\,${FPS_LIMIT%\\,}"
else export PW_FPS_LIMIT="${FPS_LIMIT%\\,}"
fi
if [[ -n "$MH_FONT_SIZE" ]] if [[ -n "$MH_FONT_SIZE" ]]
then GUI_MH_RESULT="${GUI_MH_RESULT}${MH_FONT_SIZE}" then GUI_MH_RESULT="${GUI_MH_RESULT}${MH_FONT_SIZE}"