diff --git a/ChangeLog b/ChangeLog index c7f696d48..59d7c5a8d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -95,6 +95,8 @@ Bugs narrow characters (thanks to Roy Zuo). + Fixed bug #1191, which kept file locks active for longer than necessary, and caused the 'execute' command to be considered a 'write' command. + + Fixed bug #1194, so that $HOME has precedence over the passwd db when looking + for the user's home directory (thanks to Jakub Wilk). + Improved hyphenation by splitting on commas (even if no whitespace after). Leads to better output of, for example, 'task show', where comma-separated lists are common. diff --git a/src/Path.cpp b/src/Path.cpp index c4f4942bb..6b77388ca 100644 --- a/src/Path.cpp +++ b/src/Path.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -207,19 +208,22 @@ std::string Path::expand (const std::string& in) if (tilde != std::string::npos) { - struct passwd* pw = getpwuid (getuid ()); + const char *home = getenv("HOME"); + if (home == NULL) + { + struct passwd* pw = getpwuid (getuid ()); + home = pw->pw_dir; + } // Convert: ~ --> /home/user if (copy.length () == 1) - { - copy = pw->pw_dir; - } + copy = home; // Convert: ~/x --> /home/user/x else if (copy.length () > tilde + 1 && copy[tilde + 1] == '/') { - copy.replace (tilde, 1, pw->pw_dir); + copy.replace (tilde, 1, home); } // Convert: ~foo/x --> /home/foo/x