mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 03:44:04 +08:00
Stop insisting on trying to add /usr/bin and /bin to $PATH.
https://github.com/fish-shell/fish-shell/pull/854
This commit is contained in:
parent
ec1037fcbc
commit
85ce80d72e
63
env.cpp
63
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user