aboutsummaryrefslogtreecommitdiffhomepage
path: root/expand.cpp
diff options
context:
space:
mode:
authorGravatar David Adam <zanchey@ucc.gu.uwa.edu.au>2014-10-25 13:58:52 +0800
committerGravatar David Adam <zanchey@ucc.gu.uwa.edu.au>2014-10-26 08:50:28 +0800
commitab7af98dede422fbaf3b691e4c44e1e76e2fb18c (patch)
tree655d80e7f1c509197e5cfaf26fe25c32b3be974b /expand.cpp
parentb0e09303a6c9d49d917e811edb247dbacd23907e (diff)
expand: expand tilde to canonical paths
Work on #1133.
Diffstat (limited to 'expand.cpp')
-rw-r--r--expand.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/expand.cpp b/expand.cpp
index 0eb6a72f..ed6b6e6d 100644
--- a/expand.cpp
+++ b/expand.cpp
@@ -1633,7 +1633,6 @@ static void expand_home_directory(wcstring &input)
if (userinfo == NULL)
{
tilde_error = true;
- input[0] = L'~';
}
else
{
@@ -1641,10 +1640,17 @@ static void expand_home_directory(wcstring &input)
}
}
- if (! tilde_error)
+ wchar_t *realhome;
+ realhome = wrealpath(home, NULL);
+
+ if (! tilde_error && realhome)
{
- input.replace(input.begin(), input.begin() + tail_idx, home);
+ input.replace(input.begin(), input.begin() + tail_idx, realhome);
}
+ else
+ {
+ input[0] = L'~';
+ }
}
}