shithub: riscv

ref: 13b1ea74932158069ab1f4c584db81477d9f3551
dir: /sys/src/cmd/postscript/grabit/grabit.rc/

View raw version
#!/bin/rc
# Print a listing of an object, often a dictionary or an array. Something
# like ==, but the output is often easier to read and closer to PostScript
# that can be sent back through the interpreter.
#

POSTLIB=/sys/lib/postscript/prologues
PROLOGUE=$POSTLIB/grabit.ps

COPYFILE=
RECURSIVE=true
OMITNAMES='/Grabit /GrabitDict'

NONCONFORMING='%!PS'
ENDPROLOG='%%EndProlog'
BEGINSETUP='%%BeginSetup'
ENDSETUP='%%EndSetup'
TRAILER='%%Trailer'

SETUP=GrabitSetup

while (! ~ $#* 0 && ~ $1 -*) {
	switch ($1) {
	case -d;  RECURSIVE=false

	case -o;  shift; OMITNAMES=$OMITNAMES' '$1
	case -o*; OMITNAMES=$OMITNAMES' '`{echo $1 | sed s/-o//}

	case -C;  shift; COPYFILE=$COPYFILE' '$1
	case -C*; COPYFILE=$COPYFILE' '`{echo $1 | sed s/-C//}

	case -L;  shift; PROLOGUE=$1
	case -L*; PROLOGUE=`{echo $1 | sed s/-L//}

	case --;

	case -*;  echo $0: illegal option $1 >[1=2]; exit 1
    }
    shift
done

echo $NONCONFORMING
cat $PROLOGUE
echo $ENDPROLOG
echo $BEGINSETUP
if (~ $COPYFILE '') COPYFILE=/dev/null
cat $COPYFILE
echo 'GrabitDict begin'
echo '/recursive '$RECURSIVE' def'

echo mark
for (i in $OMITNAMES) {
	switch ($i) {
	case /*; echo $i
	case ?*; echo /$i
	}
}
echo GrabitSetup

echo end
echo $ENDSETUP

for (i) echo $i Grabit