From 6fea0b20d62b7ccd844754aebef76bd675d72165 Mon Sep 17 00:00:00 2001
From: Sam Liddicott <sam@liddicott.com>
Date: Thu, 12 Sep 2024 10:09:37 +0100
Subject: escape " in KCONFIG_CONFIG_COMMAND for do_menuconfig
The problem with composing shell frgaments in python like this:
oe_terminal("sh -c \"make %s ..." % args ...
is that if args contains " this can terminate the command that is
passed to sh -c, and the remainder of args will become additional
arguments to the shell command, available as $0 onwards.
That also has the effect of breaking the "Command failed" and
the "Press any key to continue..." messages.
This patch escapes all " and \ in args with a backslash, suitable
for composing with python.
oe_terminal("sh -c \"make %s ..." % args.replace("\"", "\\\"") ...
all instances of " become \" in the command invocation.
However those escapes may be buggy, and I'm not confident that they
are sufficient.
---
meta/classes/cml1.bbclass | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -48,7 +48,7 @@ python do_menuconfig() {
# ensure that environment variables are overwritten with this tasks 'd' values
d.appendVar("OE_TERMINAL_EXPORTS", " PKG_CONFIG_DIR PKG_CONFIG_PATH PKG_CONFIG_LIBDIR PKG_CONFIG_SYSROOT_DIR")
- oe_terminal("sh -c \"make %s; if [ \\$? -ne 0 ]; then echo 'Command failed.'; printf 'Press any key to continue... '; read r; fi\"" % d.getVar('KCONFIG_CONFIG_COMMAND'),
+ oe_terminal("sh -c \"make %s; if [ \\$? -ne 0 ]; then echo 'Command failed.'; printf 'Press any key to continue... '; read r; fi\"" % d.getVar('KCONFIG_CONFIG_COMMAND').replace("\\", "\\\\").replace("\"", "\\\""),
d.getVar('PN') + ' Configuration', d)
# FIXME this check can be removed when the minimum bitbake version has been bumped
--
2.43.0