mirror of
https://github.com/tmux/tmux.git
synced 2025-11-24 19:06:07 +00:00
Handle ~ correctly when loading a file, GitHub issue 3518.
This commit is contained in:
18
file.c
18
file.c
@@ -44,13 +44,21 @@ RB_GENERATE(client_files, client_file, entry, file_cmp);
|
||||
static char *
|
||||
file_get_path(struct client *c, const char *file)
|
||||
{
|
||||
char *path;
|
||||
const char *home;
|
||||
char *path, *full_path;
|
||||
|
||||
if (*file == '/')
|
||||
if (strncmp(file, "~/", 2) != 0)
|
||||
path = xstrdup(file);
|
||||
else
|
||||
xasprintf(&path, "%s/%s", server_client_get_cwd(c, NULL), file);
|
||||
return (path);
|
||||
else {
|
||||
home = find_home();
|
||||
if (home == NULL)
|
||||
home = "";
|
||||
xasprintf(&path, "%s%s", home, file + 1);
|
||||
}
|
||||
if (*path == '/')
|
||||
return (path);
|
||||
xasprintf(&full_path, "%s/%s", server_client_get_cwd(c, NULL), path);
|
||||
return (full_path);
|
||||
}
|
||||
|
||||
/* Tree comparison function. */
|
||||
|
||||
Reference in New Issue
Block a user