1*49537Sbostic /*- 2*49537Sbostic * Copyright (c) 1991 The Regents of the University of California. 3*49537Sbostic * All rights reserved. 4*49537Sbostic * 5*49537Sbostic * %sccs.include.redist.c% 6*49537Sbostic * 7*49537Sbostic * @(#)cat.c 5.1 (Berkeley) 05/09/91 8*49537Sbostic */ 9*49537Sbostic 10*49537Sbostic int eval; 11*49537Sbostic 12*49537Sbostic main(argc, argv) 13*49537Sbostic int argc; 14*49537Sbostic char **argv; 15*49537Sbostic { 16*49537Sbostic register int fd, nr; 17*49537Sbostic char buf[2048]; 18*49537Sbostic 19*49537Sbostic if (*++argv && **argv == '-') { 20*49537Sbostic err("no options available", 0); 21*49537Sbostic _exit(1); 22*49537Sbostic } 23*49537Sbostic for (eval = 0; *argv; ++argv) 24*49537Sbostic if ((fd = open(*argv, 0, 0)) < 0) 25*49537Sbostic err(*argv, 1); 26*49537Sbostic else { 27*49537Sbostic while ((nr = read(fd, buf, sizeof(buf))) > 0) 28*49537Sbostic if (write(1, buf, nr) != nr) { 29*49537Sbostic err(*argv, 1); 30*49537Sbostic break; 31*49537Sbostic } 32*49537Sbostic if (nr == -1) 33*49537Sbostic err(*argv, 1); 34*49537Sbostic } 35*49537Sbostic _exit(eval); 36*49537Sbostic } 37*49537Sbostic 38*49537Sbostic #define PROGNAME "cat: " 39*49537Sbostic #include "errfunction" 40