From c21c4b2739da7e8a66b455fe7da690d924f5ebd8 Mon Sep 17 00:00:00 2001 From: Gitea Date: Sun, 13 Dec 2020 14:17:23 -0600 Subject: [PATCH] Moved to using optind --- tee.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tee.c b/tee.c index 2915116..92527f4 100644 --- a/tee.c +++ b/tee.c @@ -17,20 +17,13 @@ int main(int argc, char * argv[]) { case 'i': signal(SIGINT, SIG_IGN); break; } } - - while(strcmp("-a", argv[start_arg]) == 0 || - strcmp("-i", argv[start_arg]) == 0 || - strcmp("-ai", argv[start_arg]) == 0 || - strcmp("-ia", argv[start_arg]) == 0) { - start_arg++; - } FILE * files[27] = { 0 }; char * mode = append_mode == 1 ? "a+" : "w+"; int j = 0; - for(int i = start_arg; i < argc && j < 27; i++) { + for(int i = optind; i < argc && j < 27; i++) { files[j++] = fopen(argv[i], mode); if(files == NULL) { fprintf(stderr, "%s: could not open/create file %s\n", argv[0], argv[i]);