sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit a16f603b205d30ad5aa1adb75d8e285ab0d26f97
parent 85efaad43b62f999713589c64134dd2d2aff32a5
Author: Robert Ransom <rransom.8774@gmail.com>
Date:   Mon, 21 May 2012 23:33:36 +0000

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).
Diffstat:
MTODO | 2--
Muniq.c | 5+++--
2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/TODO b/TODO @@ -54,8 +54,6 @@ tr string1 [string2] unexpand [-a] [-t N] [file...] -uniq [-diuc] [input [output]] - unlink file who diff --git a/uniq.c b/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;