[hackers] [sbase] uniq: Lobotomize for POSIX-subset compatibility || Robert Ransom

From: <hg_AT_suckless.org>
Date: Tue, 22 May 2012 13:08:54 +0200 (CEST)

changeset: 133:9187cbaf2ea3
user: Robert Ransom <rransom.8774_AT_gmail.com>
date: Mon May 21 23:33:36 2012 +0000
files: TODO uniq.c
description:
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).


diff -r aeb195b41b70 -r 9187cbaf2ea3 TODO
--- a/TODO Mon May 21 23:24:28 2012 +0000
+++ b/TODO Mon May 21 23:33:36 2012 +0000
_AT_@ -54,8 +54,6 @@
 
 unexpand [-a] [-t N] [file...]
 
-uniq [-diuc] [input [output]]
-
 unlink file
 
 who
diff -r aeb195b41b70 -r 9187cbaf2ea3 uniq.c
--- a/uniq.c Mon May 21 23:24:28 2012 +0000
+++ b/uniq.c Mon May 21 23:33:36 2012 +0000
_AT_@ -41,12 +41,13 @@
 
         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;
Received on Tue May 22 2012 - 13:08:54 CEST

This archive was generated by hypermail 2.3.0 : Tue May 22 2012 - 13:12:15 CEST