diff options
author | 2012-05-06 14:53:19 -0700 | |
---|---|---|
committer | 2012-05-06 14:53:19 -0700 | |
commit | 99b51ce6eadcc93027c6edf9a0def836ac050870 (patch) | |
tree | a5a985c2f9dc1ffd18cbdfc8266a0107d54d6699 | |
parent | e0baab2722b54e044baa13b4321e1e40a2e0be7b (diff) |
Fix to better support CDPATH
-rw-r--r-- | builtin_set.cpp | 4 | ||||
-rw-r--r-- | complete.cpp | 6 | ||||
-rw-r--r-- | env.cpp | 3 | ||||
-rw-r--r-- | path.cpp | 9 |
4 files changed, 16 insertions, 6 deletions
diff --git a/builtin_set.cpp b/builtin_set.cpp index a02bc94f..e2b3c2a2 100644 --- a/builtin_set.cpp +++ b/builtin_set.cpp @@ -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" ); } /** diff --git a/complete.cpp b/complete.cpp index fd51b226..b3218a3e 100644 --- a/complete.cpp +++ b/complete.cpp @@ -1009,8 +1009,12 @@ 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); if( (wcschr( cmd, L'/') != 0) || (cmd[0] == L'~' ) ) @@ -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}; + @@ -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 ); |