/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1992-2010 AT&T Intellectual Property *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* David Korn
* AT&T Bell Laboratories
*
* tee
*/
static const char usage[] =
"[-?\n@(#)$Id: tee (AT&T Research) 2009-06-19 $\n]"
"[+NAME?tee - duplicate standard input]"
"[+DESCRIPTION?\btee\b copies standard input to standard output "
"and to zero or more files. The options determine whether "
"the specified files are overwritten or appended to. The "
"\btee\b utility does not buffer output. If writes to any "
"\afile\a fail, writes to other files continue although \btee\b "
"will exit with a non-zero exit status.]"
"[+?The number of \afile\a operands that can be specified is limited "
"by the underlying operating system.]"
"[a:append?Append the standard input to the given files rather "
"than overwriting them.]"
"[i:ignore-interrupts?Ignore SIGINT signal.]"
"[l:linebuffer?Set the standard output to be line buffered.]"
"\n"
"\n[file ...]\n"
"\n"
"[+EXIT STATUS?]{"
"[+0?All files copies successfully.]"
"[+>0?An error occurred.]"
"}"
"[+SEE ALSO?\bcat\b(1), \bsignal\b(3)]"
;
#include <cmd.h>
#include <ls.h>
#include <sig.h>
typedef struct Tee_s
{
int line;
} Tee_t;
/*
* This discipline writes to each file in the list given in handle
*/
static ssize_t
{
register const char* bp;
register const char* ep;
register ssize_t r;
do
{
{
return -1;
bp += r;
}
return n;
}
static void
{
register int* hp;
register int n;
if (tp)
{
close(n);
}
}
int
{
register int* hp;
register char* cp;
int line;
if (argc <= 0)
{
{
}
return 0;
}
line = -1;
for (;;)
{
{
case 'a':
continue;
case 'i':
continue;
case 'l':
line = -1;
else
continue;
case ':':
break;
case '?':
break;
}
break;
}
if (error_info.errors)
{
argv++;
argc--;
}
#endif
if (argc > 0)
{
{
if (context)
{
else
hp++;
}
tp = 0;
else
{
*hp = -1;
}
}
else
}
return error_info.errors;
}