>> On Sun, 11 Jan 2009 20:08:18 -0600, 
>> Jeffrey Goldberg <jeff...@goldmark.org> said:

J> if [ $UID -ne 0 ] ; then ...
J> Does anyone have a recommendation of how to run this simple test in /bin/sh
J> and how to write tests reasonably portably?

   I think your best bet for comparisons like this is to use case.  I started
   doing that back in the days when '[' would start a separate program:

     case "$UID" in
       0) echo am root ;;
       *) echo not root ;;

   I use "test" for things relating to file access:

     die() {
         echo "$@" >& 2
         exit 1

     test -f /etc/passwd || die "Your system is seriously hosed"

Karl Vogel                      I don't speak for the USAF or my company

If men ruled the world #12: Instead of wasting money on an expensive
engagement ring, your fiancee would get a giant foam hand that said,
"You're #1!"
freebsd-questions@freebsd.org mailing list
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"

Reply via email to