k9core

Unnamed repository
Log | Files | Refs | LICENSE

commit 8627b3bf15a155263524e361fdc51f5a4738fe4d
parent 997b2ed44ccdbe53697b4953aee67bf8fb69c832
Author: qorg11 <qorg@vxempire.xyz>
Date:   Sat, 28 Nov 2020 22:07:59 +0100

shit to cat.c read the diff lmao

Diffstat:
Msrc/cat.c | 11+++++------
1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/cat.c b/src/cat.c @@ -2,6 +2,9 @@ #include <fcntl.h> #include <unistd.h> #include <getopt.h> +#include <errno.h> +#include <string.h> + int cat(int fd,const char *filename) { @@ -12,10 +15,7 @@ cat(int fd,const char *filename) fd = open(filename, O_RDONLY); if (fd == -1) - { - fprintf(stderr,"Error opening file\n"); - return 1; - } + fprintf(stderr,"error opening %s: %s\n",filename,strerror(errno)); while((c = read(fd,buf,sizeof(buf))) > 0) write(1,buf,c); @@ -28,8 +28,7 @@ main(int argc, char *argv[]) if(argc == 1) cat(0,NULL); - else - for(int i = optind; i<argc;i++) + else for(int i = optind; i<argc;i++) { int c = getopt(argc, argv, "u"); cat(1,argv[i]);