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
|
@ -18,19 +18,12 @@ int main(int argc, char * argv[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 };
|
FILE * files[27] = { 0 };
|
||||||
|
|
||||||
char * mode = append_mode == 1 ? "a+" : "w+";
|
char * mode = append_mode == 1 ? "a+" : "w+";
|
||||||
|
|
||||||
int j = 0;
|
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);
|
files[j++] = fopen(argv[i], mode);
|
||||||
if(files == NULL) {
|
if(files == NULL) {
|
||||||
fprintf(stderr, "%s: could not open/create file %s\n", argv[0], argv[i]);
|
fprintf(stderr, "%s: could not open/create file %s\n", argv[0], argv[i]);
|
||||||
|
|
Loading…
Reference in a new issue