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.
This commit is contained in:
parent
ab3a577a43
commit
0ca81e7cec
|
@ -144,8 +144,9 @@ Vector<String> generate_env(StringView cmdline, const Context& context, const Sh
|
||||||
StringView name{match[2].first, match[2].second};
|
StringView name{match[2].first, match[2].second};
|
||||||
|
|
||||||
auto match_name = [&](const String& s) {
|
auto match_name = [&](const String& s) {
|
||||||
return s.substr(0_byte, name.length()) == name and
|
// 4_byte because of the initial `kak_` prefix
|
||||||
s.substr(name.length(), 1_byte) == "=";
|
return s.substr(4_byte, name.length()) == name and
|
||||||
|
s.substr(4_byte + name.length(), 1_byte) == "=";
|
||||||
};
|
};
|
||||||
if (any_of(env, match_name))
|
if (any_of(env, match_name))
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user