1
0
Fork 0

add -n option to finish feature parity with tee

This commit is contained in:
dtb 2024-01-15 13:55:05 -07:00
parent ec4b07e522
commit f311a55cff
1 changed files with 9 additions and 3 deletions

12
mm/mm.c
View File

@ -1,4 +1,5 @@
#include <errno.h> /* errno */
#include <signal.h> /* signal(2), SIG_ERR, SIG_IGN, SIGINT */
#include <stdio.h> /* fclose(3), fopen(3), fprintf(3), getc(3), putc(3),
* setvbuf(3), size_t, _IONBF, NULL */
#include <stdlib.h> /* free(3), realloc(3) */
@ -235,8 +236,8 @@ oserr(char *s, char *r){
static int
usage(char *s){
fprintf(stderr, "Usage: %s (-ehu) (-i [input])... (-o [output])...\n",
s);
fprintf(stderr, "Usage: %s (-aehnu)"
" (-i [input])... (-o [output])...\n", s);
return EX_USAGE;
}
@ -272,7 +273,7 @@ int main(int argc, char *argv[]){
unbuffered = 0;
while((c = getopt(argc, argv, "ehi:o:u")) != -1)
while((c = getopt(argc, argv, "ehi:no:u")) != -1)
switch(c){
case 'a':
io[1].fmode = amode;
@ -300,6 +301,11 @@ int main(int argc, char *argv[]){
}
terminate(io);
return oserr(argv[0], optarg);;
case 'n':
if(signal(SIGINT, SIG_IGN) != SIG_ERR)
break;
terminate(io);
return oserr(argv[0], "-n");
case 'u':
unbuffered = 1;
break;