aboutsummaryrefslogtreecommitdiffhomepage
path: root/path.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-05-06 14:53:19 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-05-06 14:53:19 -0700
commit99b51ce6eadcc93027c6edf9a0def836ac050870 (patch)
treea5a985c2f9dc1ffd18cbdfc8266a0107d54d6699 /path.cpp
parente0baab2722b54e044baa13b4321e1e40a2e0be7b (diff)
Fix to better support CDPATH
Diffstat (limited to 'path.cpp')
-rw-r--r--path.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/path.cpp b/path.cpp
index 4003644c..05b20c13 100644
--- a/path.cpp
+++ b/path.cpp
@@ -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 );