#!/bin/sh 

if [ -f ./X-ref ] ; then
  # Create mirror of all listed pairs
  awk -F: '{printf ("%s:%s\n",$2,$1)}' ./X-ref > /tmp/X-ref
  # Append current list, sort and make unique.
  cat ./X-ref >>! /tmp/X-ref && sort /tmp/X-ref | uniq >! ./X-ref

  # Verify valid users
  awk -F: '{print $1}' X-ref | uniq > /tmp/listed
  foreach x (`cat /tmp/listed`)
    grep ^$x races:players || echo Warning\! $x not in player file
  end 
  exit 0
else
  echo "X-ref missing"
  exit 1
endif
