Date: Mon, 19 Nov 2012 20:15:22 +0100 From: Mateusz Guzik <mjguzik@gmail.com> To: Eitan Adler <lists@eitanadler.com> Cc: freebsd-current Current <freebsd-current@freebsd.org> Subject: Re: prompt w/ uid 0 for cshrc Message-ID: <20121119191521.GA22292@dft-labs.eu> In-Reply-To: <CAF6rxgnAb2oWPmhSMYtm-F1N4LFruyv3g3nhkPNp=X%2BnipCX3A@mail.gmail.com> References: <CAF6rxg=V4gbOKOfB%2BJ-fzxHDjqducd8C7d7f1Oxz-UxbquVKeg@mail.gmail.com> <20121118234426.GA16628@dft-labs.eu> <CAF6rxgnAb2oWPmhSMYtm-F1N4LFruyv3g3nhkPNp=X%2BnipCX3A@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Nov 19, 2012 at 10:45:35AM -0500, Eitan Adler wrote: > On 18 November 2012 18:44, Mateusz Guzik <mjguzik@gmail.com> wrote: > > Just take user name from id -nu. > > While that does provide the $user value I want, id is in /usr/bin/ > which may not be mounted. > Is there a builtin which provides similar functionality? > Valid point, but should not happen a lot when unprivileged accounts are involved, so I suggest the following (pseudo-sh-code): if [ -x /usr/bin/id ]; then up=$(id -nu); else if [ $uid = 0 ]; then up="root"; else up="($uid)" fi -- Mateusz Guzik <mjguzik gmail.com>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20121119191521.GA22292>