#!/bin/sh
# List a user's available sandboxes
# lssb [--rc rcFile]
# Copyright (C) 2010 - 2018 FARGOS Development, LLC
# $Id$
#
#progName=`basename $0`
originDir=`dirname ${0}`
rcFile="${HOME}/.sandboxrc"
verbose=0

while test $# -gt 0
do
	case "${1}" in
	-h | -help | --help)
		printf "usage: %s [-v] [--rc rcFile]\n" "${0}" >&2
		printf "  --rc = alternate rc file, default is \"%s\"\n" "${rcFile}" >&2
		exit 1
		;;
	-rc | --rc)
		rcFile="${2}"
		shift
		;;
	-v)
		verbose=1
		;;
	-*)
		printf "%s: unrecognized option \"%s\"\n" "${0}" "${1}" >&2
		exit 1
		;;
	*)
		printf "%s: unrecognized argument \"%s\"\n" "${0}" "${1}" >&2
		exit 1
		;;
	esac
	shift
done
sbNames=`awk '/_sbname_/ { print $2 }' "${rcFile}" | sort`
for name in ${sbNames}
do
	if test ${verbose} -eq 1
	then
		sbRoot=`${originDir}/getsbattr -sb ${name} sbroot`
		sbDesc=`${originDir}/getsbattr -sb ${name} description`
		printf "%-12s %-30s %s\n" "${name}" "${sbRoot}" "${sbDesc}"
	else
		echo ${name}
	fi
done
exit 0
