From 58b29fb5d11a3454f357ed6a0cbb1fd6bd263131 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Sun, 18 Nov 2018 22:22:15 +0100 Subject: [PATCH] Revert "Remove unnecessary "string_set_contains" function" I have no idea why this worked or passed the tests? This reverts commit 1836e704c456567ca534885c3923879abceb0261. Fixes #5349. --- src/env.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/env.cpp b/src/env.cpp index d04d211c6..33e301dfc 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -286,11 +286,19 @@ static env_universal_t *uvars() { return s_universal_variables; } // so we don't bother to sort them. using string_set_t = const wchar_t *const[]; +template +bool string_set_contains(const T &set, const wchar_t *val) { + for (const wchar_t *entry : set) { + if (!wcscmp(val, entry)) return true; + } + return false; +} + /// Check if a variable may not be set using the set command. static bool is_read_only(const wchar_t *val) { const string_set_t env_read_only = {L"PWD", L"SHLVL", L"history", L"status", L"version", L"fish_pid", L"hostname", L"_", L"fish_private_mode"}; - return contains(env_read_only, val) || + return string_set_contains(env_read_only, val) || (in_private_mode() && wcscmp(L"fish_history", val) == 0); }