Hi,
I've just changed context_foil() as it was one of the setters of
‘mypath’.
commit d8ca46fabc26469be325b73a73dcc26e70681eb5
Author: Ralph Corderoy <ralph@inputplus.co.uk>
Date: Thu May 13 13:46:20 2021 +0100
sbr/path.c: add set_mypath() to factor out repeated code.
set_mypath() sets the existing global ‘mypath’ which really holds
the home-directory's path. As getenv(3) and getpwuid(3)'s result
can be invalidated by further library calls, a value they return is
mh_xstrdup()'d; not all the old bits of code replaced by a call to
set_mypath() were doing this.
Also add more explicit error messages if set_mypath() has trouble
finding the home directory's path.
Not really understanding context_foil()'s purpose, I was a bit wary of
changing it though I expect it's a like-for-like change and everything
is okay; all 117 tests pass.
From its comment, I get the rough idea.
* Foil search of users .mh_profile
/* We set context to NULL to indicate that no context file
* is to be read. (Using /dev/null doesn't work because we
* would try to lock it, which causes timeouts with some
* locking methods.)
*/
post(8) calls it if passed the undocumented ‘-library’.
nmh_init() calls it if told not to read the context file, and post(8),
slocal(1), and mh-install(1) are the ones which tell it that.
Why do we want to foil the search of .mh_profile and avoid reading, and
presumably mainly writing, context? And is this a good way to achieve
it, or just a bit of a backdoor way which fitted given it would have
been awkward to do a more large-scale change?
BTW, ‘mypath’. Is ‘homedir’ a better name? It's not a path as in
$PATH.
--
Cheers, Ralph.