#!/bin/sh
# unpack an lbr file into a subdirectory,
# and unsqueeze/uncrunch files if needed
# rjm 94/6/3

if [ "$*" = "" ]; then
  echo "usage: unlbr lbrfile1 [lbrfile2 ... ]"
fi

for i in $*; do
  dirname=`basename $i .lbr`
  mkdir $dirname
  cd $dirname
  lar e ../$i

  for j in *.?q*; do
    if [ "$j" != "*.?q*" ]; then
      xusq $j;rm -f $j
    fi
  done

  for j in *.?z*; do
    if [ "$j" != "*.?z*" ]; then
      uncr $j;rm -f $j
    fi
  done

  cd ..
done
