From a16f603b205d30ad5aa1adb75d8e285ab0d26f97 Mon Sep 17 00:00:00 2001 From: Robert Ransom Date: Mon, 21 May 2012 23:33:36 +0000 Subject: [PATCH] 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). --- TODO | 2 -- uniq.c | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index 91aa2a6..20be4b8 100644 --- 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 index 303eaa4..fe1448f 100644 --- a/uniq.c +++ b/uniq.c @@ -41,12 +41,13 @@ main(int argc, char *argv[]) if(optind == argc) uniq(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;