Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Nov 2012 11:24:26 -0800
From:      Tim Kientzle <tim@kientzle.com>
To:        jb <jb.1234abcd@gmail.com>
Cc:        freebsd-current@freebsd.org
Subject:   Re: prompt w/ uid 0 for cshrc
Message-ID:  <F58D04B5-C9B7-4B8E-9876-92CF8DBE3CB7@kientzle.com>
In-Reply-To: <loom.20121119T174504-575@post.gmane.org>
References:  <CAF6rxg=V4gbOKOfB%2BJ-fzxHDjqducd8C7d7f1Oxz-UxbquVKeg@mail.gmail.com> <20121118234426.GA16628@dft-labs.eu> <CAF6rxgnAb2oWPmhSMYtm-F1N4LFruyv3g3nhkPNp=X%2BnipCX3A@mail.gmail.com> <loom.20121119T174504-575@post.gmane.org>

index | next in thread | previous in thread | raw e-mail


On Nov 19, 2012, at 8:46 AM, jb wrote:

> Eitan Adler <lists <at> eitanadler.com> writes:
> 
>> 
>> 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.
> 
> /rescue/id

Bad idea:
  * /rescue tools are not part of the "standard" world
  * /rescue tools are sometimes not installed
  * Quite a few people have customized the rescue tools to adding or omitting things suitable for their particular installation.
  * /rescue tools are not guaranteed to be functionally identical to the non-rescue versions.

Better to invoke 'id' in a way that produces
"reasonable" results if 'id' is unavailable.

For example:
    /bin/sh -c 'id -nu 2>/dev/null' || echo '?'

prints '?' if the id command fails or is unavailable.

Tim



home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?F58D04B5-C9B7-4B8E-9876-92CF8DBE3CB7>