#!/bin/ksh
# @(#)RELEASE VERSION Workshop Docs 4.0
#
# Setup AB_CARDCATALOG to view all installed WorkShop Answerbooks
#
# Answerbooks are in <installdir>/DOC4.0/lib/locale/C/ab_docs
# this script should only be called by the workshop-answerbooks script
# or by the the GUI.  A fully qualified path to execute is required.

# strip off the script name
SCRIPT_ROOT=${0%/*}
AB_DIR_LOC=../DOC4.0/lib/locale/${LC_ALL:-${LC_MESSAGES:-${LANG:-C}}}/ab_docs
AB_DIR=$SCRIPT_ROOT/$AB_DIR_LOC

# If Answerbooks where not installed, there won't be a directory
if [[ -d ${AB_DIR} ]]
then
  cd ${AB_DIR}
  product_list=$(/usr/bin/ls -1)
  
  for pd in $product_list
  do
    if [[ -d $pd ]]
    then
      AB_CARDCATALOG=$AB_DIR/$pd/ab_cardcatalog:$AB_CARDCATALOG
    fi
  done
  
  export AB_CARDCATALOG
else
  echo "Warning: The WorkShop Answerbooks do not appear to be installed."
fi

# answerbook runs "docviewer" which needs to be accessible in PATH
export PATH=/usr/openwin/bin:${PATH}
/usr/openwin/bin/answerbook $* &
    
