[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Username length inconsistencies.



On Sun, May 31, 1998 at 11:32:18PM -0400, Alex Yukhimets wrote:
> > > Sure, this would work, but I was talking about _shell_script_  way of doing 
> > > that...
> > 
> > if perl -e 'exit !!$>'; then
> > 	: root
> > else
> > 	: not
> > fi
> 
> Wow, I think I'm going to open a zoo for root-checking methods:)
> 
> Again, the above solution is OK for debhelper (as well as "id -u" one),
> but assuming that perl is present on the system is still non-portable.
> Most (if not all) commercial unices got shipped without perl... 

So in that case (although if it doesn't have perl it doesn't deserve to
be called a *n?x in my opinion) here's another for your zoo:

if which perl; then
	if perl -e 'exit !!$>'; then
		iamroot
	else
		iamnot
	fi
else
	if [ "x$USER" = "xroot" ]; then
		iamroot
	else
		iamnot
	fi
fi

But I think, that this is taking portability a little far.  Just
include a nice little C source to do it and compile it at runtime if
it's that important to you.

Dan Jacobowitz
drow@false.org


--
To UNSUBSCRIBE, email to debian-devel-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org


Reply to: