Fix to better support CDPATH

This commit is contained in:
ridiculousfish 2012-05-06 14:53:19 -07:00
parent e0baab2722
commit 99b51ce6ea
4 changed files with 16 additions and 6 deletions

View file

@ -49,9 +49,7 @@ extern wcstring stdout_buffer, stderr_buffer;
*/
static int is_path_variable( const wchar_t *env )
{
return contains( env,
L"PATH"
);
return contains(env, L"PATH", L"CDPATH" );
}
/**

View file

@ -1009,7 +1009,11 @@ void completer_t::complete_cmd( const wcstring &str, bool use_function, bool use
wchar_t *state;
std::vector<completion_t> possible_comp;
wchar_t *cdpath_cpy = wcsdup(L".");
env_var_t cdpath = env_get_string(L"CDPATH");
if (cdpath.missing_or_empty())
cdpath = L".";
wchar_t *cdpath_cpy = wcsdup(cdpath.c_str());
const bool wants_description = (type == COMPLETE_DEFAULT);

View file

@ -1525,4 +1525,5 @@ const wchar_t *env_vars::get(const wchar_t *key) const
return (iter == vars.end() ? NULL : iter->second.c_str());
}
const wchar_t * const env_vars::highlighting_keys[] = {L"PATH", L"HIGHLIGHT_DELAY", L"fish_function_path", NULL};
const wchar_t * const env_vars::highlighting_keys[] = {L"PATH", L"CDPATH", L"HIGHLIGHT_DELAY", L"fish_function_path", NULL};

View file

@ -377,7 +377,7 @@ wchar_t *path_allocate_cdpath( const wchar_t *dir, const wchar_t *wd )
// Respect CDPATH
env_var_t path = env_get_string(L"CDPATH");
if (path.missing_or_empty()) path = L".";
if (path.missing_or_empty()) path = L"."; //We'll change this to the wd if we have one
path_cpy = wcsdup( path.c_str() );
@ -385,6 +385,13 @@ wchar_t *path_allocate_cdpath( const wchar_t *dir, const wchar_t *wd )
nxt_path != NULL;
nxt_path = wcstok( 0, ARRAY_SEP_STR, &state) )
{
if (! wcscmp(nxt_path, L".") && wd != NULL) {
// nxt_path is just '.', and we have a working directory, so use the wd instead
// TODO: if nxt_path starts with ./ we need to replace the . with the wd
nxt_path = wd;
}
wchar_t *expanded_path = expand_tilde_compat( wcsdup(nxt_path) );
// debug( 2, L"woot %ls\n", expanded_path );