From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2041 invoked by alias); 2 Apr 2014 21:04:44 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 32521 Received: (qmail 8454 invoked from network); 2 Apr 2014 21:04:29 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-Originating-IP: [86.6.157.246] X-Spam: 0 X-Authority: v=2.1 cv=KflcsGoD c=1 sm=1 tr=0 a=BvYiZ/UW0Fmn8Wufq9dPrg==:117 a=BvYiZ/UW0Fmn8Wufq9dPrg==:17 a=NLZqzBF-AAAA:8 a=VZ83JZqo0B8A:10 a=uObrxnre4hsA:10 a=kj9zAlcOel0A:10 a=pGLkceISAAAA:8 a=tPpKObBMx8gjb9LqbkIA:9 a=CjuIK1q_8ugA:10 a=MSl-tDqOz04A:10 a=_dQi-Dcv4p4A:10 Date: Wed, 2 Apr 2014 21:58:54 +0100 From: Peter Stephenson To: Erik Johnson , zsh-workers@zsh.org Subject: Re: LOGNAME not properly set on FreeBSD Message-ID: <20140402215854.6012692f@pws-pc.ntlworld.com> In-Reply-To: <20140402190621.GA5323@gmail.com> References: <20140401212239.GE20508@gmail.com> <20140402102348.4ceeddad@pwslap01u.europe.root.pri> <20140402190621.GA5323@gmail.com> X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.7; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 2 Apr 2014 14:06:21 -0500 Erik Johnson 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 Web page now at http://homepage.ntlworld.com/p.w.stephenson/