mm(1): error out when given positional arguments
This commit is contained in:
parent
8d9ac33566
commit
61382c34d9
18
src/mm.c
18
src/mm.c
@ -106,6 +106,15 @@ oserr(char *s, char *r){
|
||||
} \
|
||||
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 c;
|
||||
struct Files files[2]; /* {read, write} */
|
||||
@ -178,9 +187,12 @@ int main(int argc, char *argv[]){
|
||||
k = 1;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Usage: %s (-aenu) (-i [input])..."
|
||||
" (-o [output])...\n", argv[0]);
|
||||
retval = EX_USAGE;
|
||||
retval = usage(argv[0]);
|
||||
terminate;
|
||||
}
|
||||
|
||||
if(optind != argc){
|
||||
retval = usage(argv[0]);
|
||||
terminate;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user