#!/bin/sh
# @(#) $Id: scovol.sh,v 1.2 1991/11/14 14:48:14 ronald Exp $
# produce output for scotar from permsfile
# @(#) $Id: scovol.sh,v 1.2 1991/11/14 14:48:14 ronald Exp $
usage() { echo "usage: $0 set vol" >&2; exit 1; }
die() { echo "$1" >&2; exit 1; }
test $# = 2 || usage
vol=$2 perm=$1
test -f ./etc/perms/$perm || { echo "./etc/perms/$perm not found" >&2; usage; }
case "$vol" in [0-9][0-9]) ;; *) die "vol must be just two digits";; esac
eval "`sed -n -e '/^#prd=/{s/.//p;d;}'  -e '/^#typ=/{s/.//p;d;}' \
	-e '/^#rel=/{s/.//p;d;}' -e '/^#/!q' ./etc/perms/$perm `"
test "$prd" || die "missing #prd line";
test "$typ" || die "missing #typ line";
test "$rel" || die "missing #rel line";
echo ./tmp/_lbl/prd=$prd/typ=$typ/rel=$rel/vol=$vol
/etc/fixperm -fw ./etc/perms/$perm |
	awk '{
		if (NF == 1) { 
			if (yes) { print $1; } 
		} else if ($2 == '$vol') { 
			yes = 1; 
			print $1; 
		} else { yes = 0; }
	}'
