[Top][All Lists]

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

Re: nmh 1.8RC2, xlbiff, and $HOME

From: Robert Elz
Subject: Re: nmh 1.8RC2, xlbiff, and $HOME
Date: Wed, 01 Feb 2023 04:32:30 +0700

    Date:        Tue, 31 Jan 2023 13:29:46 +0000
    From:        Ralph Corderoy <ralph@inputplus.co.uk>
    Message-ID:  <20230131132946.44A5F20340@orac.inputplus.co.uk>

  | > Similarly, in XCU 4 in the description of the cd utility:

  | Yes, but also allowed there is ‘empty’ which also triggers
  | implementation-defined.

Yes, that's because of:

  | Also, POSIX's chdir(3) says
  |            int chdir(const char *path);
  |     ERRORS
  |            The chdir() function shall fail if:
  |            ...
  |            ENOENT  A component of path does not name an existing
  |                    directory or path is an empty string.

and since some shells simply do effectively
in this case, they get an error, if HOME is unset, or empty.

Others check the value from getenv(HOME) and do something different
if it is NULL, and still others go further and check for "" as the
value, and either treat that the same as a NULL result, or in some
other way that suits them.

Note that POSIX documents what users can expect to have happen (what
can be relied upon) and only rarely mandates some specific behaviour
that the people who maintain it believe should happen, rather than
what actually does.   If HOME is unset or empty, there is no consistent
behaviour from shells, so POSIX says that.

In the case of ~ expansion, there is no system call involved (necessarily)
just string manipulation, so the case of HOME='' isn't treated specially
(though it may end up being in the next version of the standard, as this
is a case where there are some implementation differences - or perhaps
it might be decided that the implementations that don't do what the standard
currently requires are simply buggy, and leave things as they are now).
There is (as of yesterday) a POSIX bug report about this, and some other
weird case issues with ~ expansions.

  | The possible errors are now
  |     environment variable HOME is empty

The current question is why that one in particular needs to be an error.


reply via email to

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