mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-19 03:33:43 +03:00
(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.
This commit is contained in:
1 parent
cc4105f095
commit
10da95cf3f
1 file changed
+10
-5
+10
-5
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user