aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/sed
Commit message (Collapse)AuthorAgeFilesLines
* sed.1: Adjust examples to fit in one line + SPDXAlexander Ziaee2025-07-151-4/+7
| | | | | | | | | | | Examples were previously overflowing at MANWIDTH 80. Keep the same complexity but use shorter phrases to make them easier to read. Tag SPDX while here. MFC after: 3 days Reviewed by: bcr Discussed with: emaste Differential Revision: https://reviews.freebsd.org/D50867
* sed tests: Add a regression test for the c functionMark Johnston2024-12-231-0/+23
| | | | | | | Based on the test case from PR 271817 by Mohamed Akram. PR: 271817 MFC after: 2 weeks
* sed: Fix handling of an empty pattern spaceMohamed Akram2024-12-232-6/+18
| | | | | | | | Add a regression test. PR: 271791 Obtained from: OpenBSD (1.38 millert) MFC after: 2 weeks
* sed: The change ("c") command should start a new cycle.Valeriy Ushakov2024-12-172-3/+3
| | | | | | | | | | | | | | The "c" command should start the next cycle as clarified in POSIX 2024. This is also consistent with historical and gnu sed behavior. This patch is from OpenBSD by way of NetBSD with a tweak to the man page date by me. Confirmed the test case in the bug now works. PR: 271817 Obtained from: NetBSD (1.39 uwe), OpenBSD (1.39 millert) Sponsored by: Netflix
* sed: fix commandline-given expression when -e is not usedMartin Cracauer2024-11-072-5/+18
| | | | | | | | | | | | | | Make explicit sed commands (first on commandline) behave the same as those given with -e. Without this patch the following two commands behave differently, the second one being wrong: echo ab | sed -e $'1 i\\\n--' echo ab | sed $'1 i\\\n--' Reviewed by: 0mp, des, kevans Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D47377
* Remove residual blank line at start of MakefileWarner Losh2024-07-153-3/+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
* Remove copyright strings ifdef'd outWarner Losh2023-11-271-8/+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-2711-28/+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-1615-15/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-164-8/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* Remove $FreeBSD$: one-line .h patternWarner Losh2023-08-162-2/+0
| | | | Remove /^\s*\*+\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
* Additions to targets/pseudo/host-toolsSimon J. Gerraty2023-04-272-0/+17
| | | | | More tools needed to be built for Linux. These are the ones that "just work".
* Update/fix Makefile.depend for userlandSimon J. Gerraty2023-04-191-1/+0
|
* sed(1): Fix a typo in a source code commentGordon Bergling2022-06-041-1/+1
| | | | | | | - s/Initialy/Initially/ Obtained from: NetBSD MFC after: 3 days
* sed(1): Fix a typo in the manual pageGordon Bergling2022-04-201-1/+1
| | | | | | - s/occurances/occurrences/ MFC after: 3 days
* sed(1): Add a reference for a 4.4BSD manual documentGordon Bergling2021-04-081-1/+10
| | | | | Obtained from: OpenBSD MFC after: 1 week
* sed: fix hex_subst test after after r363679Kyle Evans2020-07-301-5/+3
| | | | | | | | | r363679 is in-fact the future change referenced by the comment, helpfully left and forgotten by kevans. Instead of just silently not matching, we should now be erroring out with vigor. Notes: svn path=/head/; revision=363693
* sed: treat '[' as ordinary character in 'y' commandYuri Pankov2020-07-262-4/+29
| | | | | | | | | | | | | 'y' does not handle bracket expressions, treat '[' as ordinary character and do not apply bracket expression checks (GNU sed agrees). PR: 247931 Reviewed by: pfg, kevans Tested by: antoine (exp-run), Quentin L'Hours <lhoursquentin@gmail.com> Differential Revision: https://reviews.freebsd.org/D25640 Notes: svn path=/head/; revision=363543
* sed/multi_test: print comment for current test, not next oneYuri Pankov2020-07-131-2/+3
| | | | | | | | | | | This is visible when e.g. 8.20 is failing: not ok 96 8.20 # \ in y command 8.20's comment should be '[ as an s delimiter and its escapes'. Notes: svn path=/head/; revision=363138
* Remove some more duplicate test cases I accidentally committedMateusz Piotrowski2020-06-111-36/+0
| | | | | | | | | Reported by: markj, yuripv MFC after: 2 weeks X-MFC-With: 362017 Notes: svn path=/head/; revision=362071
* Remove duplicate lines from sed testsMateusz Piotrowski2020-06-111-2/+0
| | | | | | | | | | Reported by: yuripv Approved by: pfg (src) MFC after: 2 weeks X-MFC-With: 362017 Notes: svn path=/head/; revision=362039
* Read commands from stdin when -f - is passed to sed(1)Mateusz Piotrowski2020-06-103-6/+79
| | | | | | | | | | | | | | | | | | This patch teaches sed to interpret a "-" in a special way when given as an argument to the -f flag. This behavior is also present in GNU sed. PR: 244872 Tested by: antoine (exp-run) Reviewed by: pfg, tobik (older version) Approved by: pfg (src) Relnotes: yes MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D24079 Notes: svn path=/head/; revision=362017
* sed: attempt to learn about hex escapes (e.g. \x27)Kyle Evans2020-06-072-2/+103
| | | | | | | | | | | | | | | | | | | Somewhat predictably, software often wants to use \x27/\x24 among others so that they can decline worrying about ugly escaping, if said escaping is even possible. Right now, this software is using these and getting the wrong results, as we'll interpret those as x27 and x24 respectively. Some examples of this, when an exp-run was ran, were science/octopus and misc/vifm. Go ahead and process these at all times. We allow either one or two digits, and the tests account for both. If extra digits are specified, e.g. \x2727, then the third and fourth digits are interpreted literally as one might expect. PR: 229925 MFC after: 2 weeks Notes: svn path=/head/; revision=361884
* Update SYNOPSIS section to be consistent regarding -u, -i, and -I.Benedict Reuschling2020-05-191-3/+6
| | | | | | | | | | | | | | | | | Apparently, when the -u, -i and -I options where added to sed(1), it was forgotten to add them to both lines in the SYNOPSIS section. They were only added to the second line, although they apply to both. With the updated SYNOPSIS, it is now allowed (and consistent) to run: sed -i BAK s/foo/bar/g some_file PR: 240556 Submitted by: Oliver Fromme MFC after: 5 days Notes: svn path=/head/; revision=361248
* sed: process \r, \n, and \tKyle Evans2019-12-103-8/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is both reasonable and a common GNUism that a lot of ported software expects. Universally process \r, \n, and \t into carriage return, newline, and tab respectively. Newline still doesn't function in contexts where it can't (e.g. BRE), but we process it anyways rather than passing UB \n (escaped ordinary) through to the underlying regex engine. Adding a --posix flag to disable these was considered, but sed.1 already declares this version of sed a super-set of POSIX specification and this behavior is the most likely expected when one attempts to use one of these escape sequences in pattern space. This differs from pre-r197362 behavior in that we now honor the three arguably most common escape sequences used with sed(1) and we do so outside of character classes, too. Other escape sequences, like \s and \S, will come later when GNU extensions are added to libregex; sed will likely link against libregex by default, since the GNU extensions tend to be fairly un-intrusive. PR: 229925 Reviewed by: bapt, emaste, pfg Differential Revision: https://reviews.freebsd.org/D22750 Notes: svn path=/head/; revision=355590
* pkgbase: Put a lot of binaries and lib in FreeBSD-runtimeEmmanuel Vadot2019-09-051-0/+1
| | | | | | | | | | | | All of them are needed to be able to boot to single user and be able to repair a existing FreeBSD installation so put them directly into FreeBSD-runtime. Reviewed by: bapt, gjb Differential Revision: https://reviews.freebsd.org/D21503 Notes: svn path=/head/; revision=351855
* usr.bin/sed/tests: fix one of the regression test cases by adding itsYuri Pankov2018-10-311-0/+1
| | | | | | | | | | | results file to the build. Reviewed by: kevans Approved by: kib (mentor, implicit) Differential Revision: https://reviews.freebsd.org/D17776 Notes: svn path=/head/; revision=339955
* sed: Fix -i option behavior with 'q' command.Mark Johnston2018-08-294-6/+31
| | | | | | | | | | | | | | | | Don't just exit when encountering the 'q' command if we edit file inplace, and give mf_fgets() a chance to actually handle the inplace case. Also add a regression test. Submitted by: Yuri Pankov <yuripv@yuripv.net> Approved by: re (kib) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D16798 Notes: svn path=/head/; revision=338375
* Revert r337419.Pedro F. Giffuni2018-08-161-3/+3
| | | | | | | | | | | | | | | The fix is only partial and causes an asymmetry which breaks a test in multi_test.sh. We should consider both parts of the issue found in OpenBSD[1], but for now just revert the change. [1] http://undeadly.org/cgi?action=article;sid=20180728110010 Reported by: asomers Notes: svn path=/head/; revision=337920
* sed(1): partial fix for the case of the regex delimited with '['.Pedro F. Giffuni2018-08-071-3/+3
| | | | | | | | | | | | | We don't generally support the weird case of regular expresions delimited by an opening square bracket ('[') but POSIX says that inside bracket expressions, escaping is not possible and both '[' and '\' represent themselves. PR: 230198 (exp-run) Obtained from: OpenBSD Notes: svn path=/head/; revision=337419
* sed: compile with the default WARNS level.Pedro F. Giffuni2018-07-301-2/+0
| | | | Notes: svn path=/head/; revision=336929
* sed: unsign some indexes to fix sign-compare warnings.Pedro F. Giffuni2018-07-302-9/+9
| | | | | | | | | Hinted by: OpenBSD (CVS 1.32) MFC after: 1 week Notes: svn path=/head/; revision=336926
* sed(1): Suppress implicit-fallthrough.Pedro F. Giffuni2018-07-091-0/+2
| | | | | | | | | | | | Apparently some tools are not able to determine if all the cases of a switch are covered. Make use of the attribute for cases like this. Hinted by: DragonFlyBSD GGC8 (but fixed differently) CID: 976552 Notes: svn path=/head/; revision=336143
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-206-0/+12
| | | | | | | | | | | | | | | | | 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
* Fix the last example to really replace all occurrences of the search stringBenedict Reuschling2017-04-241-1/+1
| | | | | | | | | | | | | in the file by adding the global (g) option at the end. Without it, only the first match is replaced, subsequent ones are ignored. The intention of the example is to demonstrate something else, but adding the g matches the example to what the description says. Discussed with: brd (on IRC) MFC after: 1 week Notes: svn path=/head/; revision=317378
* Add some useful examples to the sed man page.Brad Davis2017-03-271-1/+31
| | | | | | | | | Reviewed by: wblock, bcr MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D9958 Notes: svn path=/head/; revision=316030
* Renumber copyright clause 4Warner Losh2017-02-288-8/+8
| | | | | | | | | | | | 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
* Don't expect :inplace_symlink_src to fail anymore (post-r313277)Enji Cooper2017-02-071-2/+0
| | | | | | | | | | | | The S_ISREG check was restored, such that the code will again fail with in-place replacements on symlinks MFC after: 12 days X-MFC with: r313277 Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=313397
* Restore r312404:Xin LI2017-02-051-1/+1
| | | | | | | | | | | | | | Use S_ISREG instead of manual & (also it's better to compare the result from & and the pattern instead of just assuming it's one bit value). Pointed out by Tianjie Mao <tjmao tjmao com>. MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D4827 Notes: svn path=/head/; revision=313277
* Add testcases for -i with hardlinks and symlinksEnji Cooper2017-01-202-0/+62
| | | | | | | | | | | The symlink testcase is expected to fail, post-r312519 (the revert of r312404); mark it so. MFC after: 3 weeks Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=312521
* Integrate contrib/netbsd-tests/usr.bin/sed/t_sed.sh into the FreeBSD testEnji Cooper2017-01-201-0/+5
| | | | | | | | | | | | suite as usr.bin/sed/sed_test Don't expect :emptybackref to fail -- it succeeds on FreeBSD MFC after: 3 weeks Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=312520
* Revert r312404 as we need to do an exp-run and fix existing ports thatXin LI2017-01-201-1/+1
| | | | | | | | | rely on the previous behavior. Requested by: antonie (portmgr) Notes: svn path=/head/; revision=312519
* Use S_ISREG instead of manual & (also it's better to compare theXin LI2017-01-191-1/+1
| | | | | | | | | | | | | result from & and the pattern instead of just assuming it's one bit value). Pointed out by Tianjie Mao <tjmao tjmao com>. MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D4827 Notes: svn path=/head/; revision=312404
* sed(1): add LEGACY_BSDSED_COMPAT compile-time flag.Pedro F. Giffuni2016-11-041-0/+3
| | | | | | | | | | | | | | | | | In r297602, which included a __FreeBSD_version bump to 1100105, we changed sed 'i' and 'a' from discarding whitespaces to conform with what GNU and sysvish sed do. There are arguments in favor of keeping the old behavior but the new behavior is also useful for migration purposes. It seems important to at least consider the case of developers depending on the previous behavior, so add a CFLAG to enable the old behaviour. PR: 213474 MFC after: 5 days Notes: svn path=/head/; revision=308314
* sed(1): Revert r303047 "cleanup" and therefore r303572.Pedro F. Giffuni2016-08-027-177/+192
| | | | | | | | | | | | | | | While big, the change was meant to have no effect on behavior and instead so far we have found two regressions: one in the etcupdate tests and another one in the games/openttd port[1]. Revert to a known working state. We will likely have to split the patch in functional parts before bringing back the changes. PR: 195929 Reported by: danfe, madpilot [1] Notes: svn path=/head/; revision=303662