diff options
| author | Maxime Coste <mawww@kakoune.org> | 2019-06-19 22:59:42 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2019-06-23 12:04:21 +1000 |
| commit | 4b7b5d077ced7efd4f67cc619b9f2ddaa731b8d5 (patch) | |
| tree | 16cc36c7e879c24e2856282117657412a846b404 /src/shell_manager.cc | |
| parent | 8b2906a14d3395a6619c7e40d3206b75eef11b25 (diff) | |
Make quoting opt-in by using $kak_quoted_...
Diffstat (limited to 'src/shell_manager.cc')
| -rw-r--r-- | src/shell_manager.cc | 10 |
1 files changed, 6 insertions, 4 deletions
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<String> 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<String> 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<String> 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&) {} } |
