diff --git a/steamtinkerlaunch b/steamtinkerlaunch index 0006b8d2..66bbc26b 100755 --- a/steamtinkerlaunch +++ b/steamtinkerlaunch @@ -7,7 +7,7 @@ PREFIX="/usr" PROGNAME="SteamTinkerLaunch" NICEPROGNAME="Steam Tinker Launch" -PROGVERS="v14.0.20240323-1" +PROGVERS="v14.0.20240324-1 (updateConfigEntry-sed-prevent-escaping)" PROGCMD="${0##*/}" PROGINTERNALPROTNAME="Proton-stl" SHOSTL="stl" @@ -10921,17 +10921,24 @@ function updateConfigEntry { fi # only save value if it changed + # + # NOTE 24/03/2024 - the sed command was changed to prevent expanding escape sequences, + # i.e. removing backslashes from Windows paths, or interpreting `\t` as a tab character. + # please report if this causes problems! if { [ "${!CFGCAT}" != "$CFGVALUE" ] && [ "${!CFGCAT}" != "${CFGVALUE//$STLCFGDIR/STLCFGDIR}" ];} || [ -f "$FUPDATE" ]; then CFGVALUE="${CFGVALUE//$STLCFGDIR/STLCFGDIR}" if [ "$(grep -c "#${CFGCAT}=" "$CFGFILE")" -eq 1 ]; then writelog "INFO" "${FUNCNAME[0]} - Option '$CFGCAT' commented out in config '${CFGFILE##*/}' - activating it with the new value '$CFGVALUE'" - sed -i "/^#${CFGCAT}=/c$CFGCAT=\"$CFGVALUE\"" "$CFGFILE" + # sed -i "/^#${CFGCAT}=/c$CFGCAT=\"$CFGVALUE\"" "$CFGFILE" + sed -i '/^#'"${CFGCAT}"'=/c\'"${CFGCAT}=\"$CFGVALUE\"" "$CFGFILE" elif [ "$(grep -c "^${CFGCAT}=" "$CFGFILE")" -eq 0 ]; then writelog "INFO" "${FUNCNAME[0]} - '$CFGCAT' option missing in config '${CFGFILE##*/}' - adding a new line" - echo "$CFGCAT=\"$CFGVALUE\"" >> "$CFGFILE" + # echo "$CFGCAT=\"$CFGVALUE\"" >> "$CFGFILE" + printf "%s=\"%s\"\n" "${CFGCAT}" "${CFGVALUE}" >> "${CFGFILE}" else writelog "INFO" "${FUNCNAME[0]} - Option '$CFGCAT' is updated with the new value '$CFGVALUE' in config '${CFGFILE##*/}'" - sed -i "/^${CFGCAT}=/c$CFGCAT=\"$CFGVALUE\"" "$CFGFILE" + # sed -i "/^${CFGCAT}=/c$CFGCAT=\"$CFGVALUE\"" "$CFGFILE" + sed -i '/^'"${CFGCAT}"'=/c\'"${CFGCAT}=\"$CFGVALUE\"" "$CFGFILE" fi rm "$FUPDATE" 2>/dev/null fi