Sync OpenBSD patchset 559:

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:
Tiago Cunha
2009-11-22 00:13:34 +00:00
parent 1527ed0ff8
commit 1a41a3b48f
2 changed files with 4 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* $Id: cmd-string.c,v 1.26 2009-11-18 01:24:33 tcunha Exp $ */
/* $Id: cmd-string.c,v 1.27 2009-11-22 00:13:34 tcunha Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@ -332,7 +332,7 @@ cmd_string_expand_tilde(const char *s, size_t *p)
home = NULL;
if (cmd_string_getc(s, p) == '/') {
if ((home = getenv("HOME")) == NULL) {
if ((home = getenv("HOME")) == NULL || *home == '\0') {
if ((pw = getpwuid(getuid())) != NULL)
home = pw->pw_dir;
}