aboutsummaryrefslogtreecommitdiffhomepage
path: root/env.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-08-27 18:23:33 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-08-27 18:23:33 -0700
commit85ce80d72e666d51b52f8a54e8143062478286e4 (patch)
tree9add6d86764be1c1906a038c7593c54329f1c33a /env.cpp
parentec1037fcbc3c7a4c85f540a6b931d5e80cf25fd2 (diff)
Stop insisting on trying to add /usr/bin and /bin to $PATH.
Diffstat (limited to 'env.cpp')
-rw-r--r--env.cpp63
1 files changed, 5 insertions, 58 deletions
diff --git a/env.cpp b/env.cpp
index a99f1812..13f87b6c 100644
--- a/env.cpp
+++ b/env.cpp
@@ -429,68 +429,15 @@ static void universal_callback(fish_message_type_t type,
}
/**
- Make sure the PATH variable contains the essential directories
+ Make sure the PATH variable contains something
*/
static void setup_path()
{
- const wchar_t *path_el[] =
+ const env_var_t path = env_get_string(L"PATH");
+ if (path.missing_or_empty())
{
- L"/bin",
- L"/usr/bin",
- NULL
- };
-
- env_var_t path = env_get_string(L"PATH");
-
- wcstring_list_t lst;
- if (! path.missing())
- {
- tokenize_variable_array(path, lst);
- }
-
- for (size_t j=0; path_el[j] != NULL; j++)
- {
-
- bool has_el = false;
-
- for (size_t i=0; i<lst.size(); i++)
- {
- const wcstring &el = lst.at(i);
- size_t len = el.size();
-
- while ((len > 0) && (el.at(len-1)==L'/'))
- {
- len--;
- }
-
- if ((wcslen(path_el[j]) == len) &&
- (wcsncmp(el.c_str(), path_el[j], len)==0))
- {
- has_el = true;
- break;
- }
- }
-
- if (! has_el)
- {
- wcstring buffer;
-
- debug(3, L"directory %ls was missing", path_el[j]);
-
- if (!path.missing())
- {
- buffer += path;
- }
-
- buffer.append(ARRAY_SEP_STR);
- buffer.append(path_el[j]);
-
- env_set(L"PATH", buffer.empty()?NULL:buffer.c_str(), ENV_GLOBAL | ENV_EXPORT);
-
- path = env_get_string(L"PATH");
- lst.resize(0);
- tokenize_variable_array(path, lst);
- }
+ const wchar_t *value = L"/usr/bin" ARRAY_SEP_STR L"/bin";
+ env_set(L"PATH", value, ENV_GLOBAL | ENV_EXPORT);
}
}