#!/bin/bash

if [ $# -lt 1 ]; then
  echo 1>&2 "Use: `basename $0` <mappings>"
  echo 1>&2 "Synopsis: expand collapsed pairs to two lines"
  exit 1
fi

if [ "$1" != "-" -a ! -r "$1" ]; then
  echo 1>&2 "error: cannot read file [$1]"
  exit 1
fi

if [ -z "$SEPARATOR"]; then
  SEPARATOR="###SEPARATOR###"
fi
echo 1>&2 "Using separator: \"$SEPARATOR\""

if [ "$1" = "-" ]; then
  exec sed 's/'${SEPARATOR}'/\n/'
else
  exec sed 's/'${SEPARATOR}'/\n/' <$1
fi
