mirror of
https://github.com/tmux/tmux.git
synced 2024-11-16 17:39:09 +00:00
Use home from struct passwd if HOME is empty as well as if it is NULL, and fix
a style nit. Both from Tiago Cunha.
This commit is contained in:
parent
58688c48aa
commit
9b9d26f80e
@ -332,7 +332,7 @@ cmd_string_expand_tilde(const char *s, size_t *p)
|
|||||||
|
|
||||||
home = NULL;
|
home = NULL;
|
||||||
if (cmd_string_getc(s, p) == '/') {
|
if (cmd_string_getc(s, p) == '/') {
|
||||||
if ((home = getenv("HOME")) == NULL) {
|
if ((home = getenv("HOME")) == NULL || *home == '\0') {
|
||||||
if ((pw = getpwuid(getuid())) != NULL)
|
if ((pw = getpwuid(getuid())) != NULL)
|
||||||
home = pw->pw_dir;
|
home = pw->pw_dir;
|
||||||
}
|
}
|
||||||
|
3
cmd.c
3
cmd.c
@ -278,9 +278,8 @@ cmd_free(struct cmd *cmd)
|
|||||||
size_t
|
size_t
|
||||||
cmd_print(struct cmd *cmd, char *buf, size_t len)
|
cmd_print(struct cmd *cmd, char *buf, size_t len)
|
||||||
{
|
{
|
||||||
if (cmd->entry->print == NULL) {
|
if (cmd->entry->print == NULL)
|
||||||
return (xsnprintf(buf, len, "%s", cmd->entry->name));
|
return (xsnprintf(buf, len, "%s", cmd->entry->name));
|
||||||
}
|
|
||||||
return (cmd->entry->print(cmd, buf, len));
|
return (cmd->entry->print(cmd, buf, len));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user