prompt w/ uid 0 for cshrc
Mateusz Guzik
mjguzik at gmail.com
Mon Nov 19 19:15:33 UTC 2012
On Mon, Nov 19, 2012 at 10:45:35AM -0500, Eitan Adler wrote:
> On 18 November 2012 18:44, Mateusz Guzik <mjguzik at 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>
More information about the freebsd-current
mailing list