#!/bin/sh
# STTA Rev. 1.3 Copyright (c) 2001-2003 Jesús Pérez Lorenzo  --- license GNU GPL

case "$1" in
  es|ES|spa)  errorDir="Error Directorio "
              fixingFile="Ajustando fichero "
              USAGE="$0 [LANG] [Path origen] [ Path para concatenar] [Defs Dir]"
             ;;
  en|EN|eng|*) 
              errorDir="Directory Error" 
              fixingFile="Fixing File "
              USAGE="$0 [LANG] [Path origin] [Path to concatenate] [Defs Dir]"
             ;;
esac 

case "$#" in
  0|1|2|3) echo "$USAGE"
      exit 1
      ;;
esac

if [ ! -d $2 ] 
then 
   echo "$errorDir $2 "
   exit 1
fi
if [ ! -d $3 ] 
then 
   echo "$errorDir $3 "
   exit 1
fi
if [ ! -d $4 ] 
then 
   echo "$errorDir $4 "
   exit 1
fi

cd $2 
for nomfile in `ls`
do 
    cat $nomfile | sed "s,DIRDEFS,$4,g" >>$3/$nomfile
    echo "$fixingFile $nomfile "
done
