From a4b73cfe43893f2df5b7e989bea5900a7e0035bd Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Wed, 28 Jan 2026 17:49:12 -0800 Subject: [PATCH] container: root: common: allow quotations in `Pluggable` arguments Helps facilitate CLI usage; e.g., $ dfi testprofile/testuser root plugins/repo/bitcoin/bitcoin.cc 'dfi::macro::load(\"repo/test/unit.C\")' --- container/src/root/common/utility.hh | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/container/src/root/common/utility.hh b/container/src/root/common/utility.hh index 20c3daa..b1a2a56 100644 --- a/container/src/root/common/utility.hh +++ b/container/src/root/common/utility.hh @@ -26,8 +26,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -619,11 +621,17 @@ class Pluggable // Load pluggable file ::dfi::common::load(m_plug.path().absolute()); - // Execute pluggable's loader - const std::string s{ + // Prepare pluggable entry + const std::string entry{ "dfi::" + m_plug.space().outer() + "::" + m_plug.space().inner() + "::" + m_plug.space().entry()}; - ::dfi::common::line(s + "::load(\"" + m_plug.args().load() + "\")"); + + // Allow quotations in loader argument + std::stringstream arg; + arg << std::quoted(m_plug.args().load()); + + // Execute pluggable's loader + ::dfi::common::line(entry + "::load(" + arg.str() + ")"); return *this; } @@ -634,11 +642,17 @@ class Pluggable //! \since docker-finance 1.1.0 const auto& unload() const { - // Execute pluggable's unloader - const std::string s{ + // Prepare pluggable entry + const std::string entry{ "dfi::" + m_plug.space().outer() + "::" + m_plug.space().inner() + "::" + m_plug.space().entry()}; - ::dfi::common::line(s + "::unload(\"" + m_plug.args().unload() + "\")"); + + // Allow quotations in unloader argument + std::stringstream arg; + arg << std::quoted(m_plug.args().unload()); + + // Execute pluggable's unloader + ::dfi::common::line(entry + "::unload(" + arg.str() + ")"); // Unload pluggable file ::dfi::common::unload(m_plug.path().absolute());