add -n option to finish feature parity with tee
This commit is contained in:
parent
ec4b07e522
commit
f311a55cff
12
mm/mm.c
12
mm/mm.c
@ -1,4 +1,5 @@
|
|||||||
#include <errno.h> /* errno */
|
#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),
|
#include <stdio.h> /* fclose(3), fopen(3), fprintf(3), getc(3), putc(3),
|
||||||
* setvbuf(3), size_t, _IONBF, NULL */
|
* setvbuf(3), size_t, _IONBF, NULL */
|
||||||
#include <stdlib.h> /* free(3), realloc(3) */
|
#include <stdlib.h> /* free(3), realloc(3) */
|
||||||
@ -235,8 +236,8 @@ oserr(char *s, char *r){
|
|||||||
static int
|
static int
|
||||||
usage(char *s){
|
usage(char *s){
|
||||||
|
|
||||||
fprintf(stderr, "Usage: %s (-ehu) (-i [input])... (-o [output])...\n",
|
fprintf(stderr, "Usage: %s (-aehnu)"
|
||||||
s);
|
" (-i [input])... (-o [output])...\n", s);
|
||||||
|
|
||||||
return EX_USAGE;
|
return EX_USAGE;
|
||||||
}
|
}
|
||||||
@ -272,7 +273,7 @@ int main(int argc, char *argv[]){
|
|||||||
|
|
||||||
unbuffered = 0;
|
unbuffered = 0;
|
||||||
|
|
||||||
while((c = getopt(argc, argv, "ehi:o:u")) != -1)
|
while((c = getopt(argc, argv, "ehi:no:u")) != -1)
|
||||||
switch(c){
|
switch(c){
|
||||||
case 'a':
|
case 'a':
|
||||||
io[1].fmode = amode;
|
io[1].fmode = amode;
|
||||||
@ -300,6 +301,11 @@ int main(int argc, char *argv[]){
|
|||||||
}
|
}
|
||||||
terminate(io);
|
terminate(io);
|
||||||
return oserr(argv[0], optarg);;
|
return oserr(argv[0], optarg);;
|
||||||
|
case 'n':
|
||||||
|
if(signal(SIGINT, SIG_IGN) != SIG_ERR)
|
||||||
|
break;
|
||||||
|
terminate(io);
|
||||||
|
return oserr(argv[0], "-n");
|
||||||
case 'u':
|
case 'u':
|
||||||
unbuffered = 1;
|
unbuffered = 1;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user