diff options
| author | Sidharth Kshatriya <sid.kshatriya@gmail.com> | 2021-06-24 13:53:32 +0530 |
|---|---|---|
| committer | Sidharth Kshatriya <sid.kshatriya@gmail.com> | 2021-06-24 14:03:58 +0530 |
| commit | 0ca81e7cecaee96ba3f7fb7f7fc4011699431bf8 (patch) | |
| tree | 30c167bef9a7caa487c333cc0208de3066755282 /src/shell_manager.cc | |
| parent | ab3a577a43789ec556c81481ce8c9ebcc4132fa0 (diff) | |
Fix: Kakoune passed environment variables in shell invocations are repeated
If a %sh{} script refers to any variables multiple times they are all multiply
included in the environment. Example: if a %sh{} invocation refers to
${kak_buffile} 5 times, the environment will have "kak_buffile=..." repeated 5
times and so on. This repetition happens for each multiply used variable that
is passed into the environment.
The variable should, of course, be only passed into the environment once. This
commit should fix this issue.
Diffstat (limited to 'src/shell_manager.cc')
| -rw-r--r-- | src/shell_manager.cc | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/shell_manager.cc b/src/shell_manager.cc index b683ac55..ebd6af40 100644 --- a/src/shell_manager.cc +++ b/src/shell_manager.cc @@ -144,8 +144,9 @@ Vector<String> generate_env(StringView cmdline, const Context& context, const Sh StringView name{match[2].first, match[2].second}; auto match_name = [&](const String& s) { - return s.substr(0_byte, name.length()) == name and - s.substr(name.length(), 1_byte) == "="; + // 4_byte because of the initial `kak_` prefix + return s.substr(4_byte, name.length()) == name and + s.substr(4_byte + name.length(), 1_byte) == "="; }; if (any_of(env, match_name)) continue; |
