From: Jim Meyering Date: Sun, 4 Jul 2004 18:01:04 +0000 (+0000) Subject: (main): Don't pass NULL first argument to path_concat. X-Git-Tag: v5.3.0~1167 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=10da95cf3f2fa93a975c530b6dc7e04330d40acb;p=thirdparty%2Fcoreutils.git (main): Don't pass NULL first argument to path_concat. This cleans up the semantics a bit, as we no longer try to open the same file twice. --- diff --git a/src/nohup.c b/src/nohup.c index 88deba4d53..1bc7781545 100644 --- a/src/nohup.c +++ b/src/nohup.c @@ -109,19 +109,24 @@ main (int argc, char **argv) char const *file = "nohup.out"; int flags = O_CREAT | O_WRONLY | O_APPEND; mode_t mode = S_IRUSR | S_IWUSR; - int saved_errno; fd = open (file, flags, mode); if (fd == -1) { - saved_errno = errno; - in_home = path_concat (getenv ("HOME"), file, NULL); - fd = open (in_home, flags, mode); + int saved_errno = errno; + char const *home = getenv ("HOME"); + if (home) + { + in_home = path_concat (home, file, NULL); + fd = open (in_home, flags, mode); + } if (fd == -1) { int saved_errno2 = errno; error (0, saved_errno, _("failed to open %s"), quote (file)); - error (0, saved_errno2, _("failed to open %s"), quote (in_home)); + if (in_home) + error (0, saved_errno2, _("failed to open %s"), + quote (in_home)); exit (NOHUP_FAILURE); } file = in_home;