home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d8xx / d811 / bsh.lha / bsh / tee < prev    next >
Text File  |  1993-02-14  |  909b  |  38 lines

  1. local j f l mode IFS
  2. IFS="\n",f=0
  3. if #argv==1
  4.    label usage
  5.    echo "usage: tee <file1 >file2 [-a] file3"
  6.    return 10
  7. endif
  8. onerr goto err
  9. onintr goto err
  10. j=1,mode="w"
  11. while j<#argv
  12.    if argv[j]=="-a"
  13.     mode="a",j++
  14.    elseif f
  15.     goto usage
  16.    else
  17.     if (f=open(argv[j],mode)) == 0
  18.        echo >&2 cant open $argv[$j]
  19.        goto err
  20.     endif
  21.     j++
  22.    endif
  23. endwhile
  24. while 1;read l;if eof(0);break;endif;echo $l;echo >&$f $l;endwhile
  25. label err
  26. onintr return
  27. close $f
  28. return
  29. # tee - copies standard input to standard output and one other file.
  30. # tee is really used to split PIPElines:
  31. #    % ls | tee con:0/0/400/100/files | zoo aI foo.zoo
  32. # to see the list of files being passed to zoo.
  33. #
  34. # Tee is presented as is; no warrantee is either expressed or implied
  35. # as to it's suitability to any purpose whatsoever.  You assume all the
  36. # risk for all damage, even if caused by a defect in the software,
  37. # no matter how awful.
  38.