#!/bin/sh

# mkbb.cols
# SCRIPT TO DETERMINE COLUMNS TO DISPLAY
# Sean MacGuire
# Version 1.9
# Mar 13th, 2002
#
# (c) Copyright Quest Software, Inc.  1997-2002  All rights reserved.
#

if [ "$#" -eq 1 ]
then
	BBHOSTLINE="$1"
fi

if [ ! "$BBTMP" ]                      # GET DEFINITIONS IF NEEDED
then
        . $BBHOME/etc/bbdef.sh          # INCLUDE STANDARD DEFINITIONS
fi

#
# IF WE'RE CALLED WITH AN ARGUMENT WE'RE IN COMPRESSED MODE...
# THIS ARGUMENT IS "0" WHEN CALLED FROM mkbb2.sh...
#
if [ "$BBHOSTLINE" ]				# COMPRESSED MODE
then
	if [ "$BBHOSTLINE" != "0" ]		# CALLED FROM mkbb2.sh ?
	then
		BBARGS=`$BBHOME/web/mkbb.comp $BBHOSTLINE 2>/dev/null`
	fi
else
	BBARGS=" "
fi

#
# THANKS TO: Bill Petersen <brpeters@tssun7.dsccc.com>
#
if [ "$BBHOSTLINE" = "0" ]		# CALLED FROM mkbb2.sh
then
	$GREP -v "^summary" $BBTMP/BB | $SED 's/.*\.//'|$SORT|$UNIQ
else					# NORMAL COMPRESSED DISPLAY
	if [ "$BBARGS" ]		# HANDLE "NOTHING" ELEGANTLY
	then
		cd $BBLOGS
		$LS $BBARGS| $GREP "\." | $GREP -v "^dialup"|$GREP -v "^summary"|$SED 's/.*\.//'|$SORT | $UNIQ
	fi
fi
