From bc7cb1a15a67c859c8c71c4b52bb35fe9425a63d Mon Sep 17 00:00:00 2001 From: rsc Date: Sun, 23 Nov 2003 18:04:47 +0000 Subject: new utilities. the .C files compile but are renamed to avoid building automatically. --- src/cmd/cat.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/cmd/cat.c (limited to 'src/cmd/cat.c') diff --git a/src/cmd/cat.c b/src/cmd/cat.c new file mode 100644 index 00000000..ac588897 --- /dev/null +++ b/src/cmd/cat.c @@ -0,0 +1,36 @@ +#include +#include + +void +cat(int f, char *s) +{ + char buf[8192]; + long n; + + while((n=read(f, buf, (long)sizeof buf))>0) + if(write(1, buf, n)!=n) + sysfatal("write error copying %s: %r", s); + if(n < 0) + sysfatal("error reading %s: %r", s); +} + +void +main(int argc, char *argv[]) +{ + int f, i; + + argv0 = "cat"; + if(argc == 1) + cat(0, ""); + else for(i=1; i