nmh-workers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: nmh 1.8RC2, xlbiff, and $HOME


From: David Levine
Subject: Re: nmh 1.8RC2, xlbiff, and $HOME
Date: Thu, 2 Feb 2023 14:56:51 -0800

Ralph wrote:

> Hi David,
>
> > And my feeling at this point is to put out an RC3 with the 1.7
> > behavior for $HOME.
>
> Which, to be clear, is not the behaviour Ken and kre want.  :-)

I was thinking that just removing the if (!*var) statement from your
code, leaving:

    char *var = getenv("HOME");
    if (var) {
        mypath = mh_xstrdup(var);
        return;
    }

    errno = 0;
    struct passwd *pw = getpwuid(getuid());
    if (!pw) {
        if (errno)
            adios("", "getpwuid() failed");   /* "" prints errno! */
        die("password entry not found");
    }
    if (!*pw->pw_dir)
        die("password entry has empty home directory");

    mypath = mh_xstrdup(pw->pw_dir);

is the same as the 1.7 code (ignoring the string copies):

    if ((mypath = getenv("HOME")) == NULL) {
        if ((pw = getpwuid(getuid())) == NULL || *pw->pw_dir == '\0')
            adios(NULL, "cannot determine your home directory");
        else
            mypath = pw->pw_dir;
    }

What case am I missing?

David



reply via email to

[Prev in Thread] Current Thread [Next in Thread]