Bug 200553 - uniq does not support -c with -u -d
Summary: uniq does not support -c with -u -d
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 10.1-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: Ed Maste
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-31 21:23 UTC by justin
Modified: 2017-09-09 14:28 UTC (History)
2 users (show)

See Also:
emaste: mfc-stable11+
emaste: mfc-stable10-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description justin 2015-05-31 21:23:20 UTC
uniq does not allow using the -c option (print counts) with -d (or -u). Now this is acceptable according to open group spec, but both GNU, OpenBSD and NetBSD allow it, and -d -c is useful to get the non 1 counts (-u -c is not that useful...). Google shows it is a pretty common use, so would be nice to support it.
Comment 1 commit-hook freebsd_committer 2017-05-15 20:18:42 UTC
A commit references this bug:

Author: emaste
Date: Mon May 15 20:18:14 UTC 2017
New revision: 318316
URL: https://svnweb.freebsd.org/changeset/base/318316

Log:
  uniq: allow -c to be used with -d or -u

  Bring in some bits from NetBSD and lift the restriction in uniq(1) that
  -c cannot be used with the -d and -u options.  This restriction seems
  unnecessary and is supported at least by GNU, OpenBSD, and NetBSD.  Lift
  the restriction and simplify the show() logic a little bit to maintain
  functionality when -c is provided with -d/-u.

  Also with this change, -d and -u are now actually a mutually exclusive,
  albeit valid, combination.  Given that they both indicate opposite
  behavior, uniq(1) will no longer output anything if both -d and -u are
  supplied.  This is in line with NetBSD as well as GNU.

  Adjust the man page and usage() to reflect that -c is its own standalone
  option.

  PR:		200553
  Submitted by:	Kyle Evans <kevans91@ksu.edu>
  Reviewed by:	cem, emaste
  MFC after:	2 weeks
  Differential Revision:	https://reviews.freebsd.org/D10694

Changes:
  head/usr.bin/uniq/uniq.1
  head/usr.bin/uniq/uniq.c
Comment 2 commit-hook freebsd_committer 2017-05-30 16:55:26 UTC
A commit references this bug:

Author: emaste
Date: Tue May 30 16:55:16 UTC 2017
New revision: 319226
URL: https://svnweb.freebsd.org/changeset/base/319226

Log:
  MFC r318316: uniq: allow -c to be used with -d or -u

  Bring in some bits from NetBSD and lift the restriction in uniq(1) that
  -c cannot be used with the -d and -u options.  This restriction seems
  unnecessary and is supported at least by GNU, OpenBSD, and NetBSD.  Lift
  the restriction and simplify the show() logic a little bit to maintain
  functionality when -c is provided with -d/-u.

  Also with this change, -d and -u are now actually a mutually exclusive,
  albeit valid, combination.  Given that they both indicate opposite
  behavior, uniq(1) will no longer output anything if both -d and -u are
  supplied.  This is in line with NetBSD as well as GNU.

  Adjust the man page and usage() to reflect that -c is its own standalone
  option.

  PR:		200553
  Submitted by:	Kyle Evans <kevans91@ksu.edu>

Changes:
_U  stable/11/
  stable/11/usr.bin/uniq/uniq.1
  stable/11/usr.bin/uniq/uniq.c