updated gen_test_results and versions files
diff --git a/source/1.0/bin/gen_test_results.flags b/source/1.0/bin/gen_test_results.flags
new file mode 100644
index 0000000..f42e2ae
--- /dev/null
+++ b/source/1.0/bin/gen_test_results.flags
@@ -0,0 +1,12 @@
+# $Id$
+# vim:et:ft=sh:sts=2:sw=2
+#
+# Copyright 2011 Kate Ward. All Rights Reserved.
+# Released under the LGPL (GNU Lesser General Public License)
+#
+# Author: kate.ward@forestent.com (Kate Ward)
+#
+# Flag definition overrides for the gen_test_results.sh script.
+#
+
+DEFINE_string suite 'shflags_test.sh' 'unit test suite' s
diff --git a/source/1.0/bin/gen_test_results.sh b/source/1.0/bin/gen_test_results.sh
index 9d78d12..f531e0f 100755
--- a/source/1.0/bin/gen_test_results.sh
+++ b/source/1.0/bin/gen_test_results.sh
@@ -20,49 +20,38 @@
   exit 1
 }
 
-relToAbsPath()
-{
-  path_=$1
-
-  # prepend current directory to relative paths
-  echo "${path_}" |grep '^/' >/dev/null || path_="`pwd`/${path_}"
-
-  # clean up the path
-  old_=${path_}
-  while true; do
-    new_=`echo "${old_}" |sed 's/[^/]*\/\.\.\/*//g;s/\/\.\//\//'`
-    [ "${old_}" = "${new_}" ] && break
-    old_=${new_}
-  done
-
-  echo "${new_}"
-  unset path_ old_ new_
-}
-
 BASE_DIR="`dirname $0`/.."
-BASE_DIR=`relToAbsPath "${BASE_DIR}"`
-
 LIB_DIR="${BASE_DIR}/lib"
-SRC_DIR="${BASE_DIR}/src"
 
 # load libraries
-. ${SRC_DIR}/shflags || die 'unable to load shflags library'
+. ${LIB_DIR}/shflags || die 'unable to load shflags library'
+. ${LIB_DIR}/shlib || die 'unable to load shlib library'
 . ${LIB_DIR}/versions || die 'unable to load versions library'
 
-os_name=`versions_osName |tr ' ' '_'`
-os_release=`versions_osRelease |tr ' ' '_'`
+# redefining BASE_DIR now that we have the shlib functions
+BASE_DIR=`shlib_relToAbsPath "${BASE_DIR}"`
+BIN_DIR="${BASE_DIR}/bin"
+SRC_DIR="${BASE_DIR}/src"
 
+os_name=`versions_osName |sed 's/ /_/g'`
+os_version=`versions_osVersion`
+
+# load external flags
+. ${BIN_DIR}/gen_test_results.flags
+
+# define flags
 DEFINE_boolean force false 'force overwrite' f
 DEFINE_string output_dir "`pwd`" 'output dir' d
-DEFINE_string output_file "${os_name}-${os_release}.txt" 'output file' o
-FLAGS "${@:-}" || exit $?
-eval set -- "${FLAGS_ARGV}"
+DEFINE_string output_file "${os_name}-${os_version}.txt" 'output file' o
+FLAGS "${@:-}" || exit $?; shift ${FLAGS_ARGC}
 
 # determine output filename
 output="${FLAGS_output_dir:+${FLAGS_output_dir}/}${FLAGS_output_file}"
-output=`relToAbsPath "${output}"`
+output=`shlib_relToAbsPath "${output}"`
 
 # checks
+[ -n "${FLAGS_suite}" ] || die 'suite flag missing'
+
 if [ -f "${output}" ]; then
   if [ ${FLAGS_force} -eq ${FLAGS_TRUE} ]; then
     rm -f "${output}"
@@ -74,7 +63,7 @@
 touch "${output}" 2>/dev/null || die "unable to write to '${output}'"
 
 # run tests
-( cd "${SRC_DIR}"; ./shflags_test.sh |tee "${output}" )
+( cd "${SRC_DIR}"; ./${FLAGS_suite} |tee "${output}" )
 
 echo >&2
 echo "output written to '${output}'" >&2
diff --git a/source/1.0/doc/CHANGES-1.0.txt b/source/1.0/doc/CHANGES-1.0.txt
index 0016378..794283b 100644
--- a/source/1.0/doc/CHANGES-1.0.txt
+++ b/source/1.0/doc/CHANGES-1.0.txt
@@ -22,6 +22,8 @@
 Added the ability to override the use of the OS default 'getopt' command by
 defining the FLAGS_GETOPT_CMD variable.
 
+Updated gen_test_results.sh and versions from shUnit2 source.
+
 
 Changes with 1.0.3
 ------------------
diff --git a/source/1.0/lib/shlib b/source/1.0/lib/shlib
new file mode 100644
index 0000000..d294636
--- /dev/null
+++ b/source/1.0/lib/shlib
@@ -0,0 +1,40 @@
+# $Id: shlib 14 2007-02-18 19:43:41Z sfsetse $
+# vim:et:ft=sh:sts=2:sw=2
+#
+# Copyright 2011 Kate Ward. All Rights Reserved.
+# Released under the LGPL (GNU Lesser General Public License).
+#
+# Author: kate.ward@forestent.com (Kate Ward)
+#
+# Library of shell functions.
+
+# Convert a relative path into it's absolute equivalent.
+#
+# This function will automatically prepend the current working directory if the
+# path is not already absolute. It then removes all parent references (../) to
+# reconstruct the proper absolute path.
+#
+# Args:
+#   shlib_path_: string: relative path
+# Outputs:
+#   string: absolute path
+shlib_relToAbsPath()
+{
+  shlib_path_=$1
+
+  # prepend current directory to relative paths
+  echo "${shlib_path_}" |grep '^/' >/dev/null 2>&1 \
+      || shlib_path_="`pwd`/${shlib_path_}"
+
+  # clean up the path. if all seds supported true regular expressions, then
+  # this is what it would be:
+  shlib_old_=${shlib_path_}
+  while true; do
+    shlib_new_=`echo "${shlib_old_}" |sed 's/[^/]*\/\.\.\/*//g;s/\/\.\//\//'`
+    [ "${shlib_old_}" = "${shlib_new_}" ] && break
+    shlib_old_=${shlib_new_}
+  done
+  echo "${shlib_new_}"
+
+  unset shlib_path_ shlib_old_ shlib_new_
+}
diff --git a/source/1.0/lib/versions b/source/1.0/lib/versions
index b818034..20f2088 100755
--- a/source/1.0/lib/versions
+++ b/source/1.0/lib/versions
@@ -11,7 +11,15 @@
 # versions of installed shells and the OS. The library can also be run as a
 # script if set execuatable.
 
-VERSIONS_SHELLS='/bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/sh /bin/zsh'
+ARGV0=`basename "$0"`
+LSB_RELEASE='/etc/lsb-release'
+VERSIONS_SHELLS="/bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/sh /bin/zsh"
+
+TRUE=0
+FALSE=1
+ERROR=2
+
+__versions_haveStrings=${ERROR}
 
 #------------------------------------------------------------------------------
 # functions
@@ -22,68 +30,68 @@
   os_name_='unrecognized'
   os_system_=`uname -s`
   case ${os_system_} in
-    Cygwin|FreeBSD|Linux) os_name_=${os_system_} ;;
+    CYGWIN_NT-*) os_name_='Cygwin' ;;
     Darwin) os_name_='Mac OS X' ;;
-    SunOS) os_name_='Solaris' ;;
+    FreeBSD) os_name_='FreeBSD' ;;
+    Linux) os_name_='Linux' ;;
+    SunOS)
+      if grep 'OpenSolaris' /etc/release >/dev/null; then
+        os_name_='OpenSolaris'
+      else
+        os_name_='Solaris'
+      fi
+      ;;
   esac
   echo ${os_name_}
   unset os_name_ os_system_
 }
 
-versions_osRelease()
+versions_osVersion()
 {
-  os_str_='unrecognized'
+  os_version_='unrecognized'
   os_system_=`uname -s`
   os_release_=`uname -r`
   case ${os_system_} in
-    Cygwin) os_str_='unknown' ;;
-
+    CYGWIN_NT-*)
+      os_version_=`expr "${os_release_}" : '\([0-9]*\.[0-9]\.[0-9]*\).*'`
+      ;;
     Darwin)
       major_='10'
-      sub_=`echo ${os_release_} |\
-          sed 's/^[0-9]*\.\([0-9]*\)\.[0-9]*$/\1/'`
+      sub_=`echo ${os_release_} |sed 's/^[0-9]*\.\([0-9]*\)\.[0-9]*$/\1/'`
       case ${os_release_} in
         8.*) minor_='4' ;;
         9.*) minor_='5' ;;
+        10.*) minor_='6' ;;
         *) minor_='X'; sub_='X' ;;
       esac
-      os_str_="${major_}.${minor_}.${sub_}"
+      os_version_="${major_}.${minor_}.${sub_}"
       ;;
-
     FreeBSD)
-      os_str_=`echo "${os_release_}" \
-            |sed 's/\([0-9]\.[0-9]\)-RELEASE-.*/\1/'`
+      os_version_=`expr "${os_release_}" : '\([0-9]*\.[0-9]*\)-.*'`
       ;;
-
     Linux)
-      if [ -r '/etc/lsb-release' ]; then
-        os_str_=`. /etc/lsb-release && \
-            echo "${DISTRIB_ID:-}${DISTRIB_RELEASE:+-${DISTRIB_RELEASE}}"`
-      fi
-      if [ "${os_release_}" = '-' ]; then
-        os_str_=''
-        if [ -r '/etc/redhat-release' ]; then
-          os_str_=`cat /etc/redhat-release`
+      if [ -r "${LSB_RELEASE}" ]; then
+        if grep -q 'DISTRIB_ID=Ubuntu' "${LSB_RELEASE}"; then
+          os_version_=`cat "${LSB_RELEASE}" \
+            |awk -F= '$1~/DISTRIB_DESCRIPTION/{print $2}' \
+            |sed 's/"//g;s/ /-/g'`
         fi
+      elif [ -r '/etc/redhat-release' ]; then
+        os_version_=`cat /etc/redhat-release`
       fi
       ;;
-
     SunOS)
-      case ${os_release_} in
-        5.8) os_str_='8' ;;
-        5.9) os_str_='9' ;;
-        5.10) os_str_='10' ;;
-      esac
+      if grep 'OpenSolaris' /etc/release >/dev/null; then
+        os_version_=`grep 'OpenSolaris' /etc/release |awk '{print $2"("$3")"}'`
+      else
+        major_=`echo ${os_release_} |sed 's/[0-9]*\.\([0-9]*\)/\1/'`
+        minor_=`grep Solaris /etc/release |sed 's/[^u]*\(u[0-9]*\).*/\1/'`
+        os_version_="${major_}${minor_}"
+      fi
       ;;
   esac
-
-  echo ${os_str_}
-  unset os_name_ os_release_ os_str_ os_version_ major_ minor_ sub_
-}
-
-versions_osVersion()
-{
-  uname -v
+  echo ${os_version_}
+  unset os_name_ os_release_ os_version_ major_ minor_ sub_
 }
 
 versions_shellVersion()
@@ -130,6 +138,9 @@
 
 versions_shell_dash()
 {
+  eval dpkg >/dev/null 2>&1
+  [ $? -eq 127 ] && return  # return if dpkg not found
+
   dpkg -l |grep ' dash ' |awk '{print $3}'
 }
 
@@ -137,11 +148,20 @@
 {
   versions_shell_=$1
 
-  versions_version_=`strings ${versions_shell_} 2>&1 \
+  # see if --version gives a result
+  versions_version_=`${versions_shell_} --version 2>&1 \
+    |sed 's/.*\([0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]\).*/\1/'`
+
+  # --version didn't work... look into the binary
+  if [ $? -ne ${TRUE} ]; then 
+    _versions_have_strings
+    versions_version_=`strings ${versions_shell_} 2>&1 \
       |grep Version \
       |sed 's/^.*Version \(.*\)$/\1/;s/ s+ \$$//;s/ /-/g'`
-  [ -z "${versions_version_}" ] \
-      && versions_version_=`versions_shell_pdksh ${versions_shell_}`
+    [ -z "${versions_version_}" ] \
+        && versions_version_=`versions_shell_pdksh ${versions_shell_}`
+  fi
+
   echo ${versions_version_}
 
   unset versions_shell_ versions_version_
@@ -149,6 +169,7 @@
 
 versions_shell_pdksh()
 {
+  _versions_have_strings
   strings $1 2>&1 \
   |grep 'PD KSH' \
   |sed -e 's/.*PD KSH \(.*\)/\1/;s/ /-/g'
@@ -156,7 +177,30 @@
 
 versions_shell_zsh()
 {
-  echo 'echo ${ZSH_VERSION}' |$1
+  versions_shell_=$1
+
+  versions_version_=`${versions_shell_} --version 2>&1 |awk '{print $2}'`
+
+  if [ $? -ne ${TRUE} ]; then
+    versions_version_=`echo 'echo ${ZSH_VERSION}' |${versions_shell_}`
+  fi
+
+  echo ${versions_version_}
+
+  unset versions_shell_ versions_version_
+}
+
+# Determine if the 'strings' binary installed.
+_versions_have_strings()
+{
+  [ ${__versions_haveStrings} -ne ${ERROR} ] && return
+  eval strings /dev/null >/dev/null 2>&1
+  if [ $? -eq 0 ]; then
+    __versions_haveStrings=${TRUE}
+  else
+    echo 'WARN: strings not installed. try installing binutils?' >&2
+    __versions_haveStrings=${FALSE}
+  fi
 }
 
 #------------------------------------------------------------------------------
@@ -168,9 +212,9 @@
   # treat unset variables as an error
   set -u
 
-  echo "os name: `versions_osName`"
-  echo "os release: `versions_osRelease`"
-  echo "os version: `versions_osVersion`"
+  os_name=`versions_osName`
+  os_version=`versions_osVersion`
+  echo "os: ${os_name} version: ${os_version}"
 
   for shell in ${VERSIONS_SHELLS}; do
     shell_version=`versions_shellVersion ${shell}`
@@ -178,9 +222,6 @@
   done
 }
 
-VERSIONS_OS_NAME=`versions_osName`
-VERSIONS_OS_RELEASE=`versions_osRelease`
-
-if [ "`basename $0`" = 'versions' ]; then
+if [ "${ARGV0}" = 'versions' ]; then
   versions_main "$@"
 fi