Re: prompt w/ uid 0 for cshrc

From: Tim Kientzle <tim_at_kientzle.com>
Date: Fri, 23 Nov 2012 11:24:26 -0800
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
Received on Fri Nov 23 2012 - 18:25:24 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:32 UTC