diff mbox series

[1/2] data: Escape back quotes in environment

Message ID 20251114-mathieu-back_quote_devshell-v1-1-45e83df2f362@bootlin.com
State New
Headers show
Series data: Escape back quotes in environment | expand

Commit Message

Mathieu Dubois-Briand Nov. 14, 2025, 1:27 p.m. UTC
Escape back quotes in environment variables while generating environment
files, as otherwise they will generate a parsing error:
unexpected EOF while looking for matching ``'

Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
---
 lib/bb/data.py | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/lib/bb/data.py b/lib/bb/data.py
index f672a844518d..061e63386f04 100644
--- a/lib/bb/data.py
+++ b/lib/bb/data.py
@@ -171,6 +171,7 @@  def emit_var(var, o=sys.__stdout__, d = init(), all=False):
     # if we're going to output this within doublequotes,
     # to a shell, we need to escape the quotes in the var
     alter = re.sub('"', '\\"', val)
+    alter = re.sub('`', '\\`', alter)
     alter = re.sub('\n', ' \\\n', alter)
     alter = re.sub('\\$', '\\\\$', alter)
     o.write('%s="%s"\n' % (varExpanded, alter))