mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Bug #1194
- Fixed bug #1194, so that $HOME has precedence over the passwd db when looking for the user's home directory (thanks to Jakub Wilk).
This commit is contained in:
parent
a790cce6f6
commit
82bd13bc7a
2 changed files with 11 additions and 5 deletions
|
@ -95,6 +95,8 @@ Bugs
|
||||||
narrow characters (thanks to Roy Zuo).
|
narrow characters (thanks to Roy Zuo).
|
||||||
+ Fixed bug #1191, which kept file locks active for longer than necessary,
|
+ Fixed bug #1191, which kept file locks active for longer than necessary,
|
||||||
and caused the 'execute' command to be considered a 'write' command.
|
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).
|
+ Improved hyphenation by splitting on commas (even if no whitespace after).
|
||||||
Leads to better output of, for example, 'task show', where comma-separated
|
Leads to better output of, for example, 'task show', where comma-separated
|
||||||
lists are common.
|
lists are common.
|
||||||
|
|
12
src/Path.cpp
12
src/Path.cpp
|
@ -31,6 +31,7 @@
|
||||||
#include <glob.h>
|
#include <glob.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -206,20 +207,23 @@ std::string Path::expand (const std::string& in)
|
||||||
std::string::size_type slash;
|
std::string::size_type slash;
|
||||||
|
|
||||||
if (tilde != std::string::npos)
|
if (tilde != std::string::npos)
|
||||||
|
{
|
||||||
|
const char *home = getenv("HOME");
|
||||||
|
if (home == NULL)
|
||||||
{
|
{
|
||||||
struct passwd* pw = getpwuid (getuid ());
|
struct passwd* pw = getpwuid (getuid ());
|
||||||
|
home = pw->pw_dir;
|
||||||
|
}
|
||||||
|
|
||||||
// Convert: ~ --> /home/user
|
// Convert: ~ --> /home/user
|
||||||
if (copy.length () == 1)
|
if (copy.length () == 1)
|
||||||
{
|
copy = home;
|
||||||
copy = pw->pw_dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert: ~/x --> /home/user/x
|
// Convert: ~/x --> /home/user/x
|
||||||
else if (copy.length () > tilde + 1 &&
|
else if (copy.length () > tilde + 1 &&
|
||||||
copy[tilde + 1] == '/')
|
copy[tilde + 1] == '/')
|
||||||
{
|
{
|
||||||
copy.replace (tilde, 1, pw->pw_dir);
|
copy.replace (tilde, 1, home);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert: ~foo/x --> /home/foo/x
|
// Convert: ~foo/x --> /home/foo/x
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue