From 4b7b5d077ced7efd4f67cc619b9f2ddaa731b8d5 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 19 Jun 2019 22:59:42 +1000 Subject: [PATCH] Make quoting opt-in by using $kak_quoted_... --- rc/filetype/c-family.kak | 2 +- rc/filetype/crystal.kak | 8 ++++---- rc/tools/clang.kak | 4 ++-- rc/tools/ctags.kak | 6 +++--- rc/tools/doc.kak | 6 +++--- rc/tools/lint.kak | 6 +++--- src/shell_manager.cc | 10 ++++++---- 7 files changed, 22 insertions(+), 20 deletions(-) diff --git a/rc/filetype/c-family.kak b/rc/filetype/c-family.kak index e4217a0b..9a6d79e3 100644 --- a/rc/filetype/c-family.kak +++ b/rc/filetype/c-family.kak @@ -399,7 +399,7 @@ define-command -hidden c-family-alternative-file %{ dir=$(dirname "${kak_buffile}") # Set $@ to alt_dirs - eval "set -- ${kak_opt_alt_dirs}" + eval "set -- ${kak_quoted_opt_alt_dirs}" case ${file} in *.c|*.cc|*.cpp|*.cxx|*.C|*.inl|*.m) diff --git a/rc/filetype/crystal.kak b/rc/filetype/crystal.kak index d5717c76..ed7a235a 100644 --- a/rc/filetype/crystal.kak +++ b/rc/filetype/crystal.kak @@ -92,7 +92,7 @@ provide-module crystal %🐈 evaluate-commands %sh[ # Keywords - eval "set -- $kak_opt_crystal_keywords" + eval "set -- $kak_quoted_opt_crystal_keywords" regex="\\b(?:\\Q$1\\E" shift for keyword do @@ -102,7 +102,7 @@ provide-module crystal %🐈 printf 'add-highlighter shared/crystal/code/keywords regex %s 0:keyword\n' "$regex" # Attributes - eval "set -- $kak_opt_crystal_attributes" + eval "set -- $kak_quoted_opt_crystal_attributes" regex="\\b(?:\\Q$1\\E" shift for attribute do @@ -112,7 +112,7 @@ provide-module crystal %🐈 printf 'add-highlighter shared/crystal/code/attributes regex %s 0:attribute\n' "$regex" # Symbols - eval "set -- $kak_opt_crystal_operators" + eval "set -- $kak_quoted_opt_crystal_operators" # Avoid to match modules regex="(? 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&) {} }