summaryrefslogtreecommitdiff
path: root/usr.bin/uniq
Commit message (Collapse)AuthorAgeFilesLines
* Add EXAMPLES to cover all flags except -f since it is analogous to -s.Benedict Reuschling2020-06-071-1/+51
| | | | | | | | | | | | | | An EXAMPLE section was adding with some basic examples that show the use of uniq(1) with various flags. Submitted by: fernape@ Approved by: bcr@ MFC after: 4 days Relnotes: yes (EXAMPLE section for uniq(1)) Differential Revision: https://reviews.freebsd.org/D25149 Notes: svn path=/head/; revision=361891
* Support --all-repeats in uniq(1) for compatibility with gnu coreutils.Ian Lepore2019-12-152-11/+57
| | | | | | | | | | | | | | | | | | | | This adds a new -D/--all-repeats option to uniq(1), which outputs each copy of any repeated lines (as opposed to a single copy of a repeated line). You can specify a separator option to output a blank line before or after each group of repeated lines. This adds compatibility with the GNU coreutils version of uniq(1). This change also re-groups the -c, -d, -D, -u options in the usage display and man page to indicate that they are mutally exclusive of each other. This matches the posix/opengroup definition of uniq(1) command line args. Note that this change does NOT actually enforce the mutual exclusion in the code, for now, it simply documents that the arguments should be considered exclusive with each other. Differential Revision: https://reviews.freebsd.org/D22262 Notes: svn path=/head/; revision=355777
* capsicum: use a new capsicum helpers in toolsMariusz Zaborski2018-11-041-4/+3
| | | | | | | Use caph_{rights,ioctls,fcntls}_limit to simplify the code. Notes: svn path=/head/; revision=340138
* Use capsicum helpers to cache NLS data.Mariusz Zaborski2018-06-201-12/+1
| | | | Notes: svn path=/head/; revision=335397
* Convert `cap_enter() < 0 && errno != ENOSYS` to `caph_enter() < 0`.Mariusz Zaborski2018-06-191-1/+2
| | | | | | | No functional change intended. Notes: svn path=/head/; revision=335395
* uniq(1): Add some long optionsKyle Evans2018-05-022-10/+23
| | | | | | | | | | | These match GNU uniq(1) where appropriate for compatibility's sake. While here, re-sort options alphabetically by the short-option. MFC after: 1 month Notes: svn path=/head/; revision=333156
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-201-1/+3
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Notes: svn path=/head/; revision=326025
* DIRDEPS_BUILD: Update dependencies.Bryan Drewery2017-10-311-1/+0
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=325188
* Add HAS_TESTS to all Makefiles that are currently using theEnji Cooper2017-08-021-0/+1
| | | | | | | | | `SUBDIR.${MK_TESTS}+= tests` idiom. This is a follow up to r321912. Notes: svn path=/projects/make-check-sandbox/; revision=321914
* Convert traditional ${MK_TESTS} conditional idiom for including testEnji Cooper2017-08-021-3/+1
| | | | | | | | | | | | | | directories to SUBDIR.${MK_TESTS} idiom This is being done to pave the way for future work (and homogenity) in ^/projects/make-check-sandbox . No functional change intended. MFC after: 1 weeks Notes: svn path=/head/; revision=321912
* uniq: allow -c to be used with -d or -uEd Maste2017-05-152-20/+9
| | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=318316
* Renumber copyright clause 4Warner Losh2017-02-282-2/+2
| | | | | | | | | | | | Renumber cluase 4 to 3, per what everybody else did when BSD granted them permission to remove clause 3. My insistance on keeping the same numbering for legal reasons is too pedantic, so give up on that point. Submitted by: Jan Schaumann <jschauma@stevens.edu> Pull Request: https://github.com/freebsd/freebsd/pull/96 Notes: svn path=/head/; revision=314436
* Integrate .../contrib/netbsd-tests/usr.bin/uniq into the FreeBSD testEnji Cooper2017-01-143-0/+33
| | | | | | | | | suite as .../usr.bin/uniq/tests Sponsored by: Dell EMC Isilon Notes: svn path=/projects/netbsd-tests-upstream-01-2017/; revision=312127
* Remove usage of _WITH_GETLINE from usr.binBaptiste Daroussin2016-07-301-1/+0
| | | | Notes: svn path=/head/; revision=303526
* Add META_MODE support.Simon J. Gerraty2015-06-131-0/+18
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | Off by default, build behaves normally. WITH_META_MODE we get auto objdir creation, the ability to start build from anywhere in the tree. Still need to add real targets under targets/ to build packages. Differential Revision: D2796 Reviewed by: brooks imp Notes: svn path=/head/; revision=284345
| * dirdeps.mk now sets DEP_RELDIRSimon J. Gerraty2015-06-081-2/+0
| | | | | | | | Notes: svn path=/projects/bmake/; revision=284172
| * Updated dependenciesSimon J. Gerraty2014-05-161-1/+0
| | | | | | | | Notes: svn path=/projects/bmake/; revision=266219
| * Updated dependenciesSimon J. Gerraty2014-05-101-0/+2
| | | | | | | | Notes: svn path=/projects/bmake/; revision=265802
| * Merge headSimon J. Gerraty2014-04-281-1/+1
| |\ | |/ |/| | | Notes: svn path=/projects/bmake/; revision=265044
| * Merge from headSimon J. Gerraty2013-09-051-0/+42
| |\ | | | | | | | | | Notes: svn path=/projects/bmake/; revision=255263
| * | Updated dependenciesSimon J. Gerraty2013-03-111-0/+1
| | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=248169
| * | Updated dependenciesSimon J. Gerraty2013-02-161-2/+0
| | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=246868
| * | Sync FreeBSD's bmake branch with Juniper's internal bmake branch.Marcel Moolenaar2012-08-221-0/+19
| | | | | | | | | | | | | | | | | | | | | Requested by: Simon Gerraty <sjg@juniper.net> Notes: svn path=/projects/bmake/; revision=239572
* | | Update most userspace consumers of capability.h to use capsicum.h instead.Robert Watson2014-03-161-1/+1
| |/ |/| | | | | | | | | | | | | | | | | auditdistd is not updated as I will make the change upstream and then do a vendor import sometime in the next week or two. MFC after: 3 weeks Notes: svn path=/head/; revision=263234
* | Change the cap_rights_t type from uint64_t to a structure that we can extendPawel Jakub Dawidek2013-09-051-7/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in the future in a backward compatible (API and ABI) way. The cap_rights_t represents capability rights. We used to use one bit to represent one right, but we are running out of spare bits. Currently the new structure provides place for 114 rights (so 50 more than the previous cap_rights_t), but it is possible to grow the structure to hold at least 285 rights, although we can make it even larger if 285 rights won't be enough. The structure definition looks like this: struct cap_rights { uint64_t cr_rights[CAP_RIGHTS_VERSION + 2]; }; The initial CAP_RIGHTS_VERSION is 0. The top two bits in the first element of the cr_rights[] array contain total number of elements in the array - 2. This means if those two bits are equal to 0, we have 2 array elements. The top two bits in all remaining array elements should be 0. The next five bits in all array elements contain array index. Only one bit is used and bit position in this five-bits range defines array index. This means there can be at most five array elements in the future. To define new right the CAPRIGHT() macro must be used. The macro takes two arguments - an array index and a bit to set, eg. #define CAP_PDKILL CAPRIGHT(1, 0x0000000000000800ULL) We still support aliases that combine few rights, but the rights have to belong to the same array element, eg: #define CAP_LOOKUP CAPRIGHT(0, 0x0000000000000400ULL) #define CAP_FCHMOD CAPRIGHT(0, 0x0000000000002000ULL) #define CAP_FCHMODAT (CAP_FCHMOD | CAP_LOOKUP) There is new API to manage the new cap_rights_t structure: cap_rights_t *cap_rights_init(cap_rights_t *rights, ...); void cap_rights_set(cap_rights_t *rights, ...); void cap_rights_clear(cap_rights_t *rights, ...); bool cap_rights_is_set(const cap_rights_t *rights, ...); bool cap_rights_is_valid(const cap_rights_t *rights); void cap_rights_merge(cap_rights_t *dst, const cap_rights_t *src); void cap_rights_remove(cap_rights_t *dst, const cap_rights_t *src); bool cap_rights_contains(const cap_rights_t *big, const cap_rights_t *little); Capability rights to the cap_rights_init(), cap_rights_set(), cap_rights_clear() and cap_rights_is_set() functions are provided by separating them with commas, eg: cap_rights_t rights; cap_rights_init(&rights, CAP_READ, CAP_WRITE, CAP_FSTAT); There is no need to terminate the list of rights, as those functions are actually macros that take care of the termination, eg: #define cap_rights_set(rights, ...) \ __cap_rights_set((rights), __VA_ARGS__, 0ULL) void __cap_rights_set(cap_rights_t *rights, ...); Thanks to using one bit as an array index we can assert in those functions that there are no two rights belonging to different array elements provided together. For example this is illegal and will be detected, because CAP_LOOKUP belongs to element 0 and CAP_PDKILL to element 1: cap_rights_init(&rights, CAP_LOOKUP | CAP_PDKILL); Providing several rights that belongs to the same array's element this way is correct, but is not advised. It should only be used for aliases definition. This commit also breaks compatibility with some existing Capsicum system calls, but I see no other way to do that. This should be fine as Capsicum is still experimental and this change is not going to 9.x. Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=255219
* | Close uniq(1) in the capability mode sandbox and limit descriptors usingPawel Jakub Dawidek2013-07-181-0/+43
|/ | | | | | | capability rights. Notes: svn path=/head/; revision=253457
* Add missing static keywords to uniq(1)Ed Schouten2011-11-061-15/+15
| | | | Notes: svn path=/head/; revision=227193
* Remove the advertising clause from UCB copyrighted files in usr.bin. ThisJoel Dahl2010-12-112-8/+0
| | | | | | | | | | | | is in accordance with the information provided at ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change Also add $FreeBSD$ to a few files to keep svn happy. Discussed with: imp, rwatson Notes: svn path=/head/; revision=216370
* Add SIZE_MAX overflow checkAndrey A. Chernov2010-03-091-0/+2
| | | | Notes: svn path=/head/; revision=204927
* 1) Reimplement (differently) unlimited line length restricted in prev.Andrey A. Chernov2010-03-081-54/+65
| | | | | | | | | commit. 2) Honor missing the very last \n (if absent) on output. Notes: svn path=/head/; revision=204876
* Remove vestiges of old %-format which prevents build on amd64Andrey A. Chernov2010-03-061-2/+2
| | | | Notes: svn path=/head/; revision=204811
* 1) Rewrite input processing to not exit with error on the first EILSEQ foundAndrey A. Chernov2010-03-061-106/+68
| | | | | | | | | | | | | | | | | in the input data but fallback to "binary equal" check instead. POSIX says: "The input file shall be a text file", nothing more, so the text file with illegal sequence is valid input. BTW, GNU sort does not fails on EILSEQ too. 2) Speedup input processing a bit in complex cases like skipping fields, chars or ignore case. 3) Enforce the implied LINE_MAX limit (from POSIX definition of "text file" and POSIX uniq(1) description). Notes: svn path=/head/; revision=204803
* Sync getline() with comm(1):Jaakko Heinonen2009-12-171-9/+14
| | | | | | | | | | | | | - Prevent overflowing of the buffer length variable in getline() by limiting its maximum value. - Exit if reallocf(3) fails in getline(). Failure was silently considered as end-of-file. Reviewed by: ghelmer Approved by: trasz (mentor) Notes: svn path=/head/; revision=200633
* The input line length limit mentioned on the manual page was removed byJaakko Heinonen2009-12-171-5/+1
| | | | | | | | | r176119. Approved by: trasz (mentor) Notes: svn path=/head/; revision=200632
* Fix truncation of lines at LINE_MAX characters by dynamicallyGuy Helmer2008-02-081-15/+61
| | | | | | | | | extending line buffers. PR: bin/76578 Notes: svn path=/head/; revision=176119
* Fix typo.Juli Mallett2007-05-171-1/+1
| | | | Notes: svn path=/head/; revision=169639
* o) Correct for missing whitespace.Juli Mallett2007-05-171-4/+4
| | | | | | | | o) We don't need to check if ifp == stdin to give the filename, since we already know that ifn will be "stdin" if it is. Notes: svn path=/head/; revision=169638
* Fix confusing misindentation of a closing-brace. (It goes with the switch, notJuli Mallett2007-05-171-1/+1
| | | | | | | with the while.) Notes: svn path=/head/; revision=169636
* Document that uniq(1) limits input line length to LINE_MAX characters.Giorgos Keramidas2007-01-151-0/+4
| | | | | | | | | PR: docs/107578 Submitted by: Jan Schaumann, jschauma.at.netmeister.org MFC after: 3 days Notes: svn path=/head/; revision=166035
* Added the EXIT STATUS section where appropriate.Ruslan Ermilov2005-01-171-1/+1
| | | | Notes: svn path=/head/; revision=140368
* Remove a bogus check that caused empty lines not to be counted when theTim J. Robbins2004-09-141-1/+1
| | | | | | | | | -c option was given. Noticed by: sf Notes: svn path=/head/; revision=135214
* Add support for multibyte characters.Tim J. Robbins2004-07-022-35/+41
| | | | Notes: svn path=/head/; revision=131502
* Mechanically kill hard sentence breaks.Ruslan Ermilov2004-07-021-3/+3
| | | | Notes: svn path=/head/; revision=131491
* Document the fact that uniq(1) does not recognize multibyte characters.Tim J. Robbins2004-06-241-1/+5
| | | | Notes: svn path=/head/; revision=131060
* Mention the environment variables that affect the execution of uniq.Tim J. Robbins2003-04-121-4/+15
| | | | | | | | | | | | | Of particular interest is the fact that LC_COLLATE affects how uniq determines whether lines are equal. This was the subject of a fairly heated debate a year or so ago, and it turns out that the current behaviour is correct and that the standard contained an error. Now that the standard has been corrected by Cor. 1-2002, refer to 1003.1-2001 instead of the 1992 edition in the Standards section. Notes: svn path=/head/; revision=113382
* mdoc(7) police: markup polishing.Ruslan Ermilov2002-11-261-1/+1
| | | | | | | Approved by: re Notes: svn path=/head/; revision=107276
* ANSIify function definitions.David Malone2002-09-041-17/+9
| | | | | | | | | | | | Add some constness to avoid some warnings. Remove use register keyword. Deal with missing/unneeded extern/prototypes. Some minor type changes/casts to avoid warnings. Reviewed by: md5 Notes: svn path=/head/; revision=102944
* Correct the History section; uniq(1) appeared at least as early as V3.Tim J. Robbins2002-07-051-4/+5
| | | | | | | Move the section to after Standards. Notes: svn path=/head/; revision=99435
* Remove redundant description of input_file and output_file arguments.Tim J. Robbins2002-07-051-4/+0
| | | | Notes: svn path=/head/; revision=99434
* Use err instead of errx when malloc fails. "malloc" is not a helpfulTim J. Robbins2002-07-051-4/+10
| | | | | | | error message. Notes: svn path=/head/; revision=99433