Merge branch 'main' into scrut-sysexits

This commit is contained in:
dtb 2024-04-26 19:37:34 -06:00
commit 6132c9bf47
Signed by: trinity
GPG Key ID: 31FF85CCB6DC7641

View File

@ -106,6 +106,15 @@ oserr(char *s, char *r){
} \ } \
return retval return retval
/* Prints a usage text, in which s is the program being run (i.e. argv[0]), and
* returns an exit status appropriate for a usage error. */
int usage(char *s){
fprintf(stderr, "Usage: %s (-aenu) (-i [input])... (-o [output])...\n", s);
return EX_USAGE;
}
int main(int argc, char *argv[]){ int main(int argc, char *argv[]){
int c; int c;
struct Files files[2]; /* {read, write} */ struct Files files[2]; /* {read, write} */
@ -178,9 +187,12 @@ int main(int argc, char *argv[]){
k = 1; k = 1;
break; break;
default: default:
fprintf(stderr, "Usage: %s (-aenu) (-i [input])..." retval = usage(argv[0]);
" (-o [output])...\n", argv[0]); terminate;
retval = EX_USAGE; }
if(optind != argc){
retval = usage(argv[0]);
terminate; terminate;
} }