#!/bin/sh
#
# Copyright (c) 2000-2005 Easysoft Ltd. All rights reserved.
#
# $Id: tee 32 2005-03-02 17:59:57Z martin $
#
# Simple replacement for tee.
#
append="n"
if [ $# -gt 0 ];then
  if [ "$1" = "-a" ];then
    append="y"
    shift
  fi
fi
if [ "$append" != "y" ];then
  for i in $*
  do
    > $i
    if [ $? -ne 0 ];then
      echo "Failed to create $i"
      exit 1
    fi
  done
fi
stop="n"
while [ "$stop" = "n" ]
do
  read string
  if [ $? -ne 0 ];then
    stop="y"
  else
    /bin/echo $string
    for i in $*
    do
      /bin/echo $string >> $i
    done
  fi
done

