On Mon, Nov 19, 2012 at 10:45:35AM -0500, Eitan Adler wrote:
> On 18 November 2012 18:44, Mateusz Guzik <mjgu...@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>
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Reply via email to