On Tue, Jun 02, 2009 at 03:49:13PM +0200, Steffen DETTMER wrote:
> (OT)
>
> * Michael S. Zick wrote on Sun, May 31, 2009 at 08:05 -0500:
> > A more general solution would be:
> >
> > # Am I running as user 0 (root)?
> > uid=$(/usr/bin/id -u) 2>/dev/null
> > if [ $uid == 0 ] ; then
>
> BTW, shouldn't it be just one "=" (to be compliant with POSIX and
> /usr/bin/test)?
Yes, and quotes are required, just in case "id -u" fails, and
the "uid" value is empty:
if [ "$uid" = 0 ]
Michael must have had [[ ]] in mind, but forgot the outer "[]".
[[ $uid == 0 ]]
note, the "==" is actually a pattern match when the second operand is
not quoted.
$ [[ foo == f* ]] && echo match || echo no match
match
$ [[ foo == "f*" ]] && echo match || echo no match
no match
For numeric equality:
[[ $uid -eq 0 ]]
but, when comparing with 0, this returns true also when $uid is not
a number.
--
Viktor.
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [email protected]
Automated List Manager [email protected]