Moved to using optind
This commit is contained in:
parent
ae31e82b64
commit
c21c4b2739
1 changed files with 1 additions and 8 deletions
9
tee.c
9
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]);
|
||||
|
|
Loading…
Reference in a new issue