Warn when environment value is provided with quotes,
import tkinter as tk
-from tkinter import ttk
+from tkinter import ttk, messagebox
from thonny import get_workbench, languages, tktextext
from thonny.config_ui import ConfigurationPage
@@ -121,7 +121,20 @@ class GeneralConfigurationPage(ConfigurationPage):
env = []
for entry in self.env_box.text.get("1.0", "end").strip("\r\n").splitlines():
- env.append(entry.strip("\r\n"))
+ entry = entry.strip("\r\n")
+ env.append(entry)
+
+ if any(entry.endswith("'") or entry.endswith('"') for entry in env):
+ if not messagebox.askyesno(
+ tr("Warning"),
+ tr(
+ "If you quote the value of an environment variable, the quotes will"
+ " be part of the value.\nDid you intend this?"
+ ),
+ parent=self,
+ ):
+ return False
+
get_workbench().set_option("general.environment", env)
