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:
Robert Ransom 2012-05-21 23:33:36 +00:00
parent 85efaad43b
commit a16f603b20
2 changed files with 3 additions and 4 deletions

2
TODO
View File

@ -54,8 +54,6 @@ tr string1 [string2]
unexpand [-a] [-t N] [file...]
uniq [-diuc] [input [output]]
unlink file
who

5
uniq.c
View File

@ -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;