prompt w/ uid 0 for cshrc

Tim Kientzle tim at kientzle.com
Fri Nov 23 19:25:25 UTC 2012


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



More information about the freebsd-current mailing list