#!/bin/bash
touch $HOME/tmp/pstext.log
if [ x`beak $1` = x- ]; then
   cat - > $HOME/tmp/pstext.dat
   f=$HOME/tmp/pstext.dat
else
   if [ -r $1 ]; then
      f=$1
      shift
   else
      echo "No such file $1"
      exit
   fi
fi
awk '{c=$6; \
    sub(/10/,"CT",c);\
    sub(/11/,"RT",c);\
    sub( /1/,"LB",c);\
    sub( /2/,"CB",c);\
    sub( /3/,"RB",c);\
    sub( /5/,"LM",c);\
    sub( /6/,"CM",c);\
    sub( /7/,"RM",c);\
    sub( /9/,"LT",c);\
    s=$1" "$2" "$3" "$4" "$5" "c; \
    for(i=7;i<=NF;i++){s=s" "$i}; print s}' $f |\
     gmt pstext $* 2>  >(fgrep -v "Use of old style pstext input is deprecated.")
#    echo into gmt pstext $* 
#    | tee -a /tmp/pstext.log | gmt pstext $* 2>/dev/null
#    echo into gmt pstext $*
exit
