1*421bf2ddSderaadt#!/bin/sh - 2*421bf2ddSderaadt# $OpenBSD: ckscripts.sh,v 1.1 2024/08/19 01:43:23 deraadt Exp $ 3*421bf2ddSderaadt# $NetBSD: ckscripts.sh,v 1.9 1995/04/23 10:07:34 cgd Exp $ 4*421bf2ddSderaadt# 5*421bf2ddSderaadt# This script runs the .ed scripts generated by mkscripts.sh 6*421bf2ddSderaadt# and compares their output against the .r files, which contain 7*421bf2ddSderaadt# the correct output 8*421bf2ddSderaadt 9*421bf2ddSderaadtPATH="/bin:/usr/bin:/usr/local/bin/:." 10*421bf2ddSderaadtED=$1 11*421bf2ddSderaadt[ ! -x $ED ] && { echo "$ED: cannot execute"; exit 1; } 12*421bf2ddSderaadt 13*421bf2ddSderaadt# Run the *.red scripts first, since these don't generate output; 14*421bf2ddSderaadt# they exit with non-zero status 15*421bf2ddSderaadtfor i in *.red; do 16*421bf2ddSderaadt echo $i 17*421bf2ddSderaadt if $i; then 18*421bf2ddSderaadt echo "*** The script $i exited abnormally ***" 19*421bf2ddSderaadt fi 20*421bf2ddSderaadtdone >errs.o 2>&1 21*421bf2ddSderaadt 22*421bf2ddSderaadt# Run the remaining scripts; they exit with zero status 23*421bf2ddSderaadtfor i in *.ed; do 24*421bf2ddSderaadt# base=`expr $i : '\([^.]*\)'` 25*421bf2ddSderaadt# base=`echo $i | sed 's/\..*//'` 26*421bf2ddSderaadt base=`$ED - \!"echo $i" <<-EOF 27*421bf2ddSderaadt s/\..* 28*421bf2ddSderaadt EOF` 29*421bf2ddSderaadt if $base.ed; then 30*421bf2ddSderaadt if cmp -s $base.o $base.r; then :; else 31*421bf2ddSderaadt echo "*** Output $base.o of script $i is incorrect ***" 32*421bf2ddSderaadt fi 33*421bf2ddSderaadt else 34*421bf2ddSderaadt echo "*** The script $i exited abnormally ***" 35*421bf2ddSderaadt fi 36*421bf2ddSderaadtdone >scripts.o 2>&1 37*421bf2ddSderaadt 38*421bf2ddSderaadtgrep -h '\*\*\*' errs.o scripts.o 39