Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/uniq Don't pass '-' to getopt(3). My guess is that ...



details:   https://anonhg.NetBSD.org/src/rev/2c38a5efc8d3
branches:  trunk
changeset: 456103:2c38a5efc8d3
user:      uwe <uwe%NetBSD.org@localhost>
date:      Tue Apr 23 14:40:12 2019 +0000

description:
Don't pass '-' to getopt(3).  My guess is that *very* old getopt
didn't handle "--" terminator, so this code was working around it and
not quite correctly at that.

Fixes weird output from

  $ uniq --long-option
  uniq: uniq: No such file or directory

(for more fun, run that command from /usr/bin as root).

Pointed out by Andreas Krey.

diffstat:

 usr.bin/uniq/uniq.c |  9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diffs (31 lines):

diff -r 765f65820f2f -r 2c38a5efc8d3 usr.bin/uniq/uniq.c
--- a/usr.bin/uniq/uniq.c       Tue Apr 23 13:36:42 2019 +0000
+++ b/usr.bin/uniq/uniq.c       Tue Apr 23 14:40:12 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uniq.c,v 1.20 2016/10/16 06:17:51 abhinav Exp $        */
+/*     $NetBSD: uniq.c,v 1.21 2019/04/23 14:40:12 uwe Exp $    */
 
 /*
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)uniq.c     8.3 (Berkeley) 5/4/95";
 #endif
-__RCSID("$NetBSD: uniq.c,v 1.20 2016/10/16 06:17:51 abhinav Exp $");
+__RCSID("$NetBSD: uniq.c,v 1.21 2019/04/23 14:40:12 uwe Exp $");
 #endif /* not lint */
 
 #include <err.h>
@@ -75,11 +75,8 @@
        setprogname(argv[0]);
        ifp = ofp = NULL;
        obsolete(argv);
-       while ((ch = getopt(argc, argv, "-cdf:s:u")) != -1)
+       while ((ch = getopt(argc, argv, "cdf:s:u")) != -1)
                switch (ch) {
-               case '-':
-                       --optind;
-                       goto done;
                case 'c':
                        cflag = 1;
                        break;



Home | Main Index | Thread Index | Old Index