#! /bin/bash
# Last edited on 2024-03-30 17:49:02 by stolfi

# Usage: $0 <prefix>
#
# Appends the files <prefix>.bad.save and <inprefix>.good.save
#   to <prefix>.js-check, with lines preceded respectively by "- " 
#   and "+ ".  Leaves the result on <prefix>.js-check-new
#
if [[ $# -ne 1]]; then
  echo "** usage: fold-bad-good-save-into-js-check <prefix>" 1>&2
  exit 1
fi
prefix="$1"; shift

infile="${prefix}.js-check"
outfile="${prefix}.js-check-new"
tmpfile="${prefix}.js-check-tmp"

cat ${infile} > ${tmpfile}
cat ${prefix}.good.save | sed -e '1,$s/^/+ /g' >> ${tmpfile}
cat ${prefix}.bad.save | sed -e '1,$s/^/- /g' >> ${tmpfile}
sort -k2 -k1 ${tmpfile} | uniq > ${outfile}
rm ${tmpfile}

wc ${infile} ${outfile} 1>&2

