It now should print even without files specified
This commit is contained in:
parent
f510192587
commit
0ed15dd266
1 changed files with 2 additions and 7 deletions
9
tee.c
9
tee.c
|
@ -33,11 +33,6 @@ int main(int argc, char * argv[]) {
|
||||||
start_arg++;
|
start_arg++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(start_arg >= argc) {
|
|
||||||
fprintf(stderr, "%s: no file operands provided\n", argv[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
FILE * files[27] = { 0 };
|
FILE * files[27] = { 0 };
|
||||||
|
|
||||||
char * mode = append_mode == 1 ? "a+" : "w+";
|
char * mode = append_mode == 1 ? "a+" : "w+";
|
||||||
|
@ -47,7 +42,7 @@ int main(int argc, char * argv[]) {
|
||||||
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]);
|
||||||
return 2;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,5 +62,5 @@ int main(int argc, char * argv[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return file_failed == 0 ? 0 : 3;
|
return file_failed == 0 ? 0 : 2;
|
||||||
}
|
}
|
Loading…
Reference in a new issue