Bruce Momjian wrote:
> Tom Lane wrote:
>> Bruce Momjian <pgman@candle.pha.pa.us> writes:
>> > Tom Lane wrote:
>> >> (I'm not finding it right now, but I'm pretty sure that the SUS
>> >> specifies that numeric userid == 0 for superuser, whereas "root" is
>> >> not
>> >> required to be the name, so this would be more correct anyway.)
>>
>> > Can we assume 'id' is on all unix systems?
>>
>> What's your point? The script fails anyway if that bit doesn't work.
>
> Is 'id' better than what we have now if 'id' isn't widely supported?
I don't think this is really a question of portability. The variables $USER
and $LOGNAME are not always set to the current (effective) user, e.g. on
linux. That's Chris' current problem, I think. Just compare the difference
of using "su" with and without the "-l" argument:
$ su
# echo $LOGNAME ; echo $USER
mip
mip
# exit
$ su -l
# echo $LOGNAME ; echo $USER
root
root
#
Of course, if you just want to question the use of "id", that's a different
story.
Best Regards,
Michael Paesold