aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/cmp
Commit message (Collapse)AuthorAgeFilesLines
* Improve reliability of stdout tests.Dag-Erling Smørgrav2024-11-141-0/+1
| | | | | | | | | | | If the test runner is under heavy load, the command we are testing may succeed in printing to stdout before the dummy receiver has terminated. Add a short delay to reduce the likelihood of this happening. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D47572
* cmp: Check the status of stdout.Dag-Erling Smørgrav2024-10-097-49/+89
| | | | | | | | | | POSIX requires us to print an error message and exit non-zero if writing to stdout fails. This can only happen if sflag is unset. MFC after: 3 days Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D47020
* cmp: Style and type issues.Dag-Erling Smørgrav2024-10-095-11/+15
| | | | | | | MFC after: 3 days Sponsored by: Klara, Inc. Reviewed by: 0mp, markj Differential Revision: https://reviews.freebsd.org/D47019
* Remove residual blank line at start of MakefileWarner Losh2024-07-152-2/+0
| | | | | | | This is a residual of the $FreeBSD$ removal. MFC After: 3 days (though I'll just run the command on the branches) Sponsored by: Netflix
* usr.bin: Automated cleanup of cdefs and other formattingWarner Losh2023-11-274-13/+0
| | | | | | | | | | | | | | | | Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
* Remove copyright strings ifdef'd outWarner Losh2023-11-271-10/+0
| | | | | | | | | | | We've ifdef'd out the copyright strings for some time now. Go ahead and remove the ifdefs. Plus whatever other detritis was left over from other recent removals. These copyright strings are present in the comments and are largely from CSRG's attempt at adding their copyright to every binary file (which modern interpretations of the license doesn't require). Sponsored by: Netflix
* usr.bin: Remove ancient SCCS tags.Warner Losh2023-11-277-17/+0
| | | | | | | | Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl script. Sponsored by: Netflix
* Remove $FreeBSD$: one-line nroff patternWarner Losh2023-08-161-1/+0
| | | | Remove /^\.\\"\s*\$FreeBSD\$$\n/
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-165-5/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-165-10/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-161-2/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* Mark usage function as __dead2 in programs where it does not returnAlfonso Gregory2023-07-071-1/+1
| | | | | | | | In most cases, usage does not return, so mark them as __dead2. For the cases where they do return, they have not been marked __dead2. Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/735
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-122-2/+2
| | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
* Update/fix Makefile.depend for userlandSimon J. Gerraty2023-04-191-1/+2
|
* cmp: Increase buffer size for non-mmap case.Dag-Erling Smørgrav2023-01-311-0/+2
| | | | | | | MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: rpokala Differential Revision: https://reviews.freebsd.org/D38281
* cmp: Print a summary on SIGINFO.Dag-Erling Smørgrav2023-01-314-0/+32
| | | | | | | MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D38280
* cmp: initialize limit to avoid stack garbage limitsKyle Evans2021-10-211-1/+1
| | | | | | Pointy hat: kevans Fixes: 4e380e847460 ("cmp: add -n, --bytes to limit number of bytes [...]") Sponsored by: Klara, Inc.
* cmp: add -b, --print-bytesKyle Evans2021-09-2911-16/+70
| | | | | | | | This is compatible with GNU cmp. Reviewed by: bapt, markj (earlier version) Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D32074
* cmp: add -i, --ignore-initial, an alternative to skip1/skip2 argsKyle Evans2021-09-293-1/+53
| | | | | | | | This is compatible with GNU cmp. Reviewed by: markj Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D32073
* cmp: add -n, --bytes to limit number of bytes to compareKyle Evans2021-09-297-15/+57
| | | | | | | | This is compatible with GNU cmp. Reviewed by: markj Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D32072
* cmp: accept SI suffixes for skip1 and skip2Kyle Evans2021-09-294-3/+46
| | | | | | | | This is compatible with GNU cmp. Reviewed by: bapt (earlier version), markj, imp Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D32071
* cmp: fix -s (silent) when used with skip offsetsEd Maste2021-01-112-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | -s causes cmp to print nothing for differing files, for use when only the exit status is of interest. -z compares the file size first, for regular files, and fails the comparison early if they do not match. Prior to this change -s implied -z as an optimization, but this is not valid when file offsets are specified. Now, enable the -z optimization for -s only if both skip arguments are not provided / 0. Note that using -z with differing skip values will currently always fail. We may want to compare size1 - skip1 with size2 - skip2 instaead, and in any case the man page should be clarified. PR: 252542 Fixes: 3e6902efc802ab57fc4e9bf798f2d271b152e7f9 Reported by: William Ahern Reviewed by: markj MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D28071
* cmp: use C99 bool for flagsEd Maste2021-01-114-14/+17
| | | | | | | MFC after: 1 week Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D28072
* cmp(1): Add EXAMPLES sectionFernando Apesteguía2020-06-201-7/+16
| | | | | | | | | Add a small number of examples depicting the use of -l, -z and byte offsets Approved by: 0mp@ Notes: svn path=/head/; revision=362434
* cmp(1): Add EXAMPLES sectionFernando Apesteguía2020-06-161-1/+35
| | | | | | | | | | Add simple examples showing the use of -l, -z, stdin and offsets Approved by: bcr@ Differential Revision: https://reviews.freebsd.org/D25280 Notes: svn path=/head/; revision=362229
* Drop "All rights reserved" from the files I ownAlan Somers2019-03-111-1/+2
| | | | | | | | | Also, add SPDX tags where needed. MFC after: 2 weeks Notes: svn path=/head/; revision=345034
* Fix handling of rights on stdio streams, take two.Mark Johnston2019-02-254-43/+38
| | | | | | | | | | | | | | | | | | | Split the rights-limiting code into two cases: if one of the input files isn't a regular file, use caph_limit_stream(3) instead of open-coding the same logic; if both input files are regular files, and the initial attempts to map them succeed, we limit the rights on those files to CAP_MMAP_R. Add a regression test for PR 234885. PR: 234885 Reviewed by: delphij MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D19216 Notes: svn path=/head/; revision=344551
* Fix cmp(1) tests for "special" mode.Mark Johnston2019-01-211-5/+4
| | | | | | | | | | | Test failures don't seem to propagate up if atf_check is run in a pipeline. Thus, the tests continued to pass despite the bug reverted in r343245. MFC after: 1 week Notes: svn path=/head/; revision=343247
* Revert r343117.Mark Johnston2019-01-211-7/+16
| | | | | | | | | | | | It breaks the special mode specified by passing "-" as one of the input files. Revert for now while we discuss a fix. PR: 234885 Reported by: delphij MFC after: now Notes: svn path=/head/; revision=343245
* Fix handling of rights on stdio streams.Mark Johnston2019-01-171-16/+7
| | | | | | | | | | | | | | | | | | | | - Limit rights on stdio before opening input files. Otherwise, open() may return one of the standard descriptors and we end up limiting rights such that we cannot read from one of the input files. - Use caph_limit_stdio(), which suppresses EBADF, to ensure that we don't emit an error if one of the stdio streams is closed. - Don't bother further limiting rights on stdin when stdin isn't going to be used. Doing so correctly requires checking for a number of edge cases, and it doesn't provide any significant benefit. PR: 234885 Reviewed by: oshogbo MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D18860 Notes: svn path=/head/; revision=343117
* capsicum: use a new capsicum helpers in toolsMariusz Zaborski2018-11-041-6/+5
| | | | | | | Use caph_{rights,ioctls,fcntls}_limit to simplify the code. Notes: svn path=/head/; revision=340138
* Convert `cap_enter() < 0 && errno != ENOSYS` to `caph_enter() < 0`.Mariusz Zaborski2018-06-191-1/+1
| | | | | | | No functional change intended. Notes: svn path=/head/; revision=335395
* cmp(1): Provide some long optionsKyle Evans2018-05-022-4/+13
| | | | | | | | | | | | | These match GNU cmp(1) for compatibility where applicable. Future work might implement the -i option from GNU cmp(1) to express skip either in terms of both files or of the form "SKIP1:SKIP2" rather than specifying them as additional arguments to cmp(1). MFC after: 1 month Notes: svn path=/head/; revision=333157
* various: general adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. 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. No functional change intended. Notes: svn path=/head/; revision=326276
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-205-0/+10
| | | | | | | | | | | | | | | | | 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
* Renumber copyright clause 4Warner Losh2017-02-286-6/+6
| | | | | | | | | | | | 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
* Fix file descriptor leaks in cmp(1)Alan Somers2017-01-073-0/+70
| | | | | | | | | | | | | | Also, add a few test cases Reported by: Coverity CID: 271624 275338 Reviewed by: ngie MFC after: 4 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D9074 Notes: svn path=/head/; revision=311572
* DIRDEPS_BUILD: Update dependencies.Bryan Drewery2016-11-131-0/+1
| | | | | | | | MFC after: 2 weeks Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=308606
* Restrict stdin if it's not in use.Mariusz Zaborski2016-10-071-0/+8
| | | | | | | | Reviewed by: emaste, cem Differential Revision: https://reviews.freebsd.org/D8184 Notes: svn path=/head/; revision=306820
* Remove the duplicated code using Capsicum helpers.Mariusz Zaborski2016-10-071-15/+4
| | | | | | | | Reviewed by: cem, ed, bapt, emaste Differential Revision https://reviews.freebsd.org/D8140 Notes: svn path=/head/; revision=306813
* Move sys/capsicum.h includes after types.h or param.hConrad Meyer2016-09-191-1/+1
| | | | | | | | | | | This is not actually documented or even implied in style(9). Make the change to match convention. Someone should document this convention in style(9). Reported by: jhb Sponsored by: EMC Dell Isilon Notes: svn path=/head/; revision=305998
* cmp(1): CapsicumifyConrad Meyer2016-09-191-0/+37
| | | | | | | | | Reviewed by: allanjude, bapt, oshogbo Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D7912 Notes: svn path=/head/; revision=305981
* Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installedEnji Cooper2016-05-041-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | after r298107 Summary of changes: - Replace all instances of FILES/TESTS with ${PACKAGE}FILES. This ensures that namespacing is kept with FILES appropriately, and that this shouldn't need to be repeated if the namespace changes -- only the definition of PACKAGE needs to be changed - Allow PACKAGE to be overridden by callers instead of forcing it to always be `tests`. In the event we get to the point where things can be split up enough in the base system, it would make more sense to group the tests with the blocks they're a part of, e.g. byacc with byacc-tests, etc - Remove PACKAGE definitions where possible, i.e. where FILES wasn't used previously. - Remove unnecessary TESTSPACKAGE definitions; this has been elided into bsd.tests.mk - Remove unnecessary BINDIRs used previously with ${PACKAGE}FILES; ${PACKAGE}FILESDIR is now automatically defined in bsd.test.mk. - Fix installation of files under data/ subdirectories in lib/libc/tests/hash and lib/libc/tests/net/getaddrinfo - Remove unnecessary .include <bsd.own.mk>s (some opportunistic cleanup) Document the proposed changes in share/examples/tests/tests/... via examples so it's clear that ${PACKAGES}FILES is the suggested way forward in terms of replacing FILES. share/mk/bsd.README didn't seem like the appropriate method of communicating that info. MFC after: never probably X-MFC with: r298107 PR: 209114 Relnotes: yes Tested with: buildworld, installworld, checkworld; buildworld, packageworld Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=299094
* MFHGlen Barber2016-03-101-0/+11
|\ | | | | | | | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/release-pkg/; revision=296625
| * DIRDEPS_BUILD: Connect MK_TESTS.Bryan Drewery2016-03-091-0/+11
| | | | | | | | | | | | | | Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=296587
* | First pass to fix the 'tests' packages.Glen Barber2016-02-021-0/+4
|/ | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/release-pkg/; revision=295171
* Refactor the test/ Makefiles after recent changes to bsd.test.mk (r289158) andEnji Cooper2015-10-121-6/+3
| | | | | | | | | | | | | | | netbsd-tests.test.mk (r289151) - Eliminate explicit OBJTOP/SRCTOP setting - Convert all ad hoc NetBSD test integration over to netbsd-tests.test.mk - Remove unnecessary TESTSDIR setting - Use SRCTOP where possible for clarity MFC after: 2 weeks Sponsored by: EMC / Isilon Storage Divison Notes: svn path=/head/; revision=289172