* Mini tee implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
*
* This program is free software; you can redistribute it and/or modify
*/
#include "internal.h"
+#include <errno.h>
#include <stdio.h>
static const char tee_usage[] =
- "tee [OPTION]... [FILE]...\n\n"
- "Copy standard input to each FILE, and also to standard output.\n\n"
+ "tee [OPTION]... [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCopy standard input to each FILE, and also to standard output.\n\n"
"Options:\n" "\t-a\tappend to the given FILEs, do not overwrite\n"
#if 0
"\t-i\tignore interrupt signals\n"
#endif
+#endif
;
/* FileList _______________________________________________________________ */
#define FL_MAX 1024
-static FILE *FileList[FL_MAX];
+static FILE **FileList;
static int FL_end;
typedef void (FL_Function) (FILE * file, char c);
}
/* init FILE pointers */
+ FileList = calloc(FL_MAX, sizeof(FILE*));
+ if (!FileList) {
+ fprintf(stderr, "tee: %s\n", strerror(errno));
+ exit(1);
+ }
FL_end = 0;
FileList[0] = stdout;
for (; i < argc; i++) {
/* clean up */
FL_apply(tee_fclose, 0);
- exit(0);
+ /* Don't bother to close files Exit does that
+ * automagically, so we can save a few bytes */
+ /* free(FileList); */
+ return(0);
}
-/* $Id: tee.c,v 1.6 2000/02/08 19:58:47 erik Exp $ */
+/* $Id: tee.c,v 1.11 2000/06/19 17:25:40 andersen Exp $ */