actually, delete usage function

This commit is contained in:
NunoSempere 2023-09-09 00:06:56 +02:00
parent 13eb71f4ee
commit 2009c18381
2 changed files with 3 additions and 10 deletions

BIN
ww

Binary file not shown.

13
ww.c
View File

@ -31,17 +31,9 @@ int process_fn(int fn)
return 0; return 0;
} }
void usage(){
printf("Usage: ww file.txt\n");
printf(" or: cat file.txt | ww\n");
}
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
if(argc > 1 && argv[1][0] == '-' && argv[1][1] == 'h'){ if (!isatty(STDIN_FILENO)) {
usage();
return 0;
} else if (!isatty(STDIN_FILENO)) {
return process_fn(STDIN_FILENO); return process_fn(STDIN_FILENO);
} else if (argc > 1) { } else if (argc > 1) {
FILE* fp = fopen(argv[1], "r"); FILE* fp = fopen(argv[1], "r");
@ -51,7 +43,8 @@ int main(int argc, char** argv)
} }
return process_fn(fileno(fp)); return process_fn(fileno(fp));
} else { } else {
usage(); printf("Usage: ww file.txt\n");
printf(" or: cat file.txt | ww\n");
} }
return 0; return 0;
} }