From fa7787ccb87cc8c47f118c65d5bbada602323a68 Mon Sep 17 00:00:00 2001 From: joeyh Date: Thu, 16 Mar 2006 17:08:29 +0000 Subject: [PATCH] er yeah, let's check in the right stuff --- pee | Bin 11447 -> 0 bytes pee.c | 55 +++++++++++++++++++++++++++++++++++++ pee.docbook | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 132 insertions(+) delete mode 100755 pee create mode 100644 pee.c create mode 100644 pee.docbook diff --git a/pee b/pee deleted file mode 100755 index b4874b7539c7b061209769ca53e87d7afd825384..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11447 zcmcgy3v^t?d7k@N``TJtFTWDpu(D+%_n=)%R*a2#*p@6?L}0LNAQ*bR+P%^)thAeb z7@OE9wuJyyQ4t}W1WFs+kj5>fal#`mnBvwP3TaM4ogSK|Jq_&vB8p4w1}JSzx8FB& zN4k=oS0SA}voqh!|C*Wq&YhV%pV`paZWxBp!4#GtT03YvElAsbOVzZ9h?p)KM7^jJ z(@?~^mVKZ>dHgBL zXdxSIR=iLxZQpp+Hpxpn7#XVlC;|S$h?N@n>C6D0jlARISxDJul>dtY?brIyJdB45 z=n7GRNc&|Us^UriH~Od>X$|5fQ}9(juJ`Ld?&CTiZ}Rc5kJtJ5$1sHQ5rEGmUcNOGFBH6jaNXX%Y`6Qv!5?ZOq*V-3{fQ_9U>s#ICXw!IZIn6ia&w_8Loc=d_FJQ{?(tcB&PQ#Tf@dtic zmBgm_Dup5JL4QsIF~=nY=i_*U;5_W-5FGZiNT;JCN14LWKF<`6`9-D}$OoCi!5(4? zXM30_obV7+IQOGW;fRNs!oeSB3Vqv#UK=>+jJ*RB#yTN?>re&!G#D^uOg{cVfLlV={R0Hv-#I!iI zoOqwav^=$nI43b%kXlQ;Lt?fhwTbv@iP@sm)x>Lok&32&|DBc5-a5yS8ip$%PTn?sd=;11GCS>}S|O^6diO;IW~>lRqk# zD{o(b(H|%qm3Ll_%;uqIPNCFSG;;I;>O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~M3p*ipwhzjP&Vk1TNQj7M^XVyUMG+FZAF>*g(P zXGhmo+(vWVwn^xU*6}KAadH{2=p~~qEh|@u920Dw-DKA7&1Add8CPzZ+<0jhZlz(n z<0eaeeY>@S4Og{I$k(8K%epH!xEfKJ&QC~{`!Ol?L+%(JdZ}|hx9yWxt-G?L6}EB= zuzkzNcf0ENBv2raU_ryN3es%s+`N8Wr@Ohmy=%i(ck8{ zZ{aPM7yg3S?a8^RTlKBKV2!#VI8lNV5;s}Mx~X`7GK13 vqf=L|S{d#2if%697E`7ETcX{&gd8e)E;Wf~@(oCJIdT$#8`S&DuWJ4;GNKpL diff --git a/pee.c b/pee.c new file mode 100644 index 0000000..35ad37d --- /dev/null +++ b/pee.c @@ -0,0 +1,55 @@ +#include +#include + +/* Licensed under the GPL + * Copyright (c) Miek Gieben, 2006 + */ + +/* like tee(1), but then connect to other programs using + * pipes _and_ output to standard output + */ + +void +close_pipes(FILE **p, size_t i) +{ + size_t j; + for (j = 0; j < i; j++) + pclose(p[j]); +} + +int +main(int argc, char **argv) { + size_t i, r; + FILE **pipes; + char buf[BUFSIZ]; + + pipes = malloc(((argc - 1) * sizeof *pipes)); + if (!pipes) + exit(EXIT_FAILURE); + + for (i = 1; i < argc; i++) { + pipes[i - 1] = popen(argv[i], "w"); + if (!pipes[i - 1]) { + fprintf(stderr, "Can not open pipe to '%s\'\n", argv[i]); + close_pipes(pipes, i); + + exit(EXIT_FAILURE); + } + } + argc--; + + while(!feof(stdin) && (!ferror(stdin))) { + r = fread(buf, sizeof(char), BUFSIZ, stdin); + for(i = 0; i < argc; i++) { + if (fwrite(buf, sizeof(char), r, pipes[i]) != r) { + fprintf(stderr, "Write error to `%s\'\n", argv[i + 1]); + close_pipes(pipes, i); + exit(EXIT_FAILURE); + } + fwrite(buf, sizeof(char), r, stdout); + } + } + close_pipes(pipes, argc); + + exit(EXIT_SUCCESS); +} diff --git a/pee.docbook b/pee.docbook new file mode 100644 index 0000000..970dc81 --- /dev/null +++ b/pee.docbook @@ -0,0 +1,77 @@ + + + + + + + + +
+ joey@kitenet.net +
+ + Joey + Hess + + 2006-03-14 +
+ + + pee + 1 + + + + pee + tee standard input to pipes + + + + + pee + + "command" + + + + + + DESCRIPTION + + pee is like tee + but for pipes. Each command is run and standard input is + copied into it, as well as being sent to stdout. + + + + + SEE ALSO + + + + tee1 + + + + +
-- 2.39.5