uniq: Lobotomize for POSIX-subset compatibility
POSIX uniq(1) is required to write to its second argument, if one is given. The multiple-input feature I accidentally added might be useful, but users and scripts who rely on it would be put at risk for data loss if they ever run into a POSIX uniq(1).
This commit is contained in:
parent
85efaad43b
commit
a16f603b20
2
TODO
2
TODO
@ -54,8 +54,6 @@ tr string1 [string2]
|
||||
|
||||
unexpand [-a] [-t N] [file...]
|
||||
|
||||
uniq [-diuc] [input [output]]
|
||||
|
||||
unlink file
|
||||
|
||||
who
|
||||
|
5
uniq.c
5
uniq.c
@ -41,12 +41,13 @@ main(int argc, char *argv[])
|
||||
|
||||
if(optind == argc)
|
||||
uniq(stdin, "<stdin>");
|
||||
else for(; optind < argc; optind++) {
|
||||
else if(optind == argc - 1) {
|
||||
if(!(fp = fopen(argv[optind], "r")))
|
||||
eprintf("fopen %s:", argv[optind]);
|
||||
uniq(fp, argv[optind]);
|
||||
fclose(fp);
|
||||
}
|
||||
} else
|
||||
enprintf(2, "too many arguments\n");
|
||||
uniq_finish();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
Loading…
Reference in New Issue
Block a user