From 4b7b5d077ced7efd4f67cc619b9f2ddaa731b8d5 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 19 Jun 2019 22:59:42 +1000 Subject: Make quoting opt-in by using $kak_quoted_... --- src/shell_manager.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/shell_manager.cc') diff --git a/src/shell_manager.cc b/src/shell_manager.cc index 5abad543..9c0604dd 100644 --- a/src/shell_manager.cc +++ b/src/shell_manager.cc @@ -134,12 +134,13 @@ pid_t spawn_shell(const char* shell, StringView cmdline, Vector generate_env(StringView cmdline, const Context& context, const ShellContext& shell_context) { - static const Regex re(R"(\bkak_(\w+)\b)"); + static const Regex re(R"(\bkak_(quoted_)?(\w+)\b)"); Vector kak_env; for (auto&& match : RegexIterator{cmdline.begin(), cmdline.end(), re}) { - StringView name{match[1].first, match[1].second}; + StringView name{match[2].first, match[2].second}; + Quoting quoting = match[1].matched ? Quoting::Shell : Quoting::Raw; auto match_name = [&](const String& s) { return s.substr(0_byte, name.length()) == name and @@ -152,9 +153,10 @@ Vector generate_env(StringView cmdline, const Context& context, const Sh try { const String& value = var_it != shell_context.env_vars.end() ? - var_it->value : ShellManager::instance().get_val(name, context, Quoting::Shell); + var_it->value : ShellManager::instance().get_val(name, context, quoting); - kak_env.push_back(format("kak_{}={}", name, value)); + StringView quoted{match[1].first, match[1].second}; + kak_env.push_back(format("kak_{}{}={}", quoted, name, value)); } catch (runtime_error&) {} } -- cgit v1.2.3