Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: LOGNAME not properly set on FreeBSD
On Wed, 2 Apr 2014 14:06:21 -0500
Erik Johnson <palehose@xxxxxxxxx> wrote:
> Python os.getlogin() does indeed show "erik" instead of "root". So this
> may just be a difference between glibc and BSD libc. Either way, it
> "just works" in bash, sh, csh, tcsh, and ksh, as can be seen below, so
> I believe there is an argument for making it work properly in FreeBSD as
> well, or at the very least adding some wording to the zshparam manpage
> which makes this difference in behavior clear.
Hmm... to me, having LOGNAME *not* report the same as getlogin() is
"just not working". Presumably there's some reason why getlogin() does
what it does and it doesn't seem to me to be the shell's job to second
guess system calls. POSIX seems to agree with me --- to be fair, this
isn't for the variable, it's for the command "logname", but it would be
confusing if they were different.
The logname utility shall write the user's login name to standard
output. The login name shall be the string that would be returned by
the getlogin() function defined in the System Interfaces volume of
POSIX.1-2008. Under the conditions where the getlogin() function would
fail, the logname utility shall write a diagnostic message to standard
error and exit with a non-zero exit status.
However, there may be some documented prior art for LOGNAME that I'm
missing --- the history of shell development isn't necessarily particularly
rational.
It certainly makes sense to document it in any case.
diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo
index cf2ad34..8d95355 100644
--- a/Doc/Zsh/params.yo
+++ b/Doc/Zsh/params.yo
@@ -621,7 +621,9 @@ item(tt(LOGNAME))(
If the corresponding variable is not set in the environment of the
shell, it is initialized to the login name corresponding to the
current login session. This parameter is exported by default but
-this can be disabled using the tt(typeset) builtin.
+this can be disabled using the tt(typeset) builtin. The value
+is set to the string returned by the manref(getlogin)(3) system call
+if that is available.
)
vindex(MACHTYPE)
item(tt(MACHTYPE))(
--
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author