summaryrefslogtreecommitdiffstats
path: root/usr.bin/sed (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Add some references, most of these were removed when we stopped buildingjsg2021-03-081-2/+11
| | | | | | and installing USD/SMM/PSD docs. jmc@ agrees with the direction, ok millert@ on an earlier diff
* replace fgetln(3) with getline(3) in sednaddy2021-01-311-16/+11
| | | | | Partly from Johann Oskarsson for Illumos/FreeBSD. ok millert@
* double word fixes; from varik valeforjmc2020-10-161-3/+3
|
* Un-const what we pass to dirname(3).martijn2020-10-131-3/+5
| | | | Original diff by and OK naddy@
* correct inaccurate and misplaced information in CAVEATSschwarze2018-12-101-10/+24
| | | | | | and move it in part to the DESCRIPTION, in part to STANDARDS; triggered by a loosely related bug report from Lars dot Nooden at gmail dot com; OK jmc@, and no opposition when shown on bugs@
* revert previous, it breaks regress and the llvm, gtk+2, and gtk+3 portsschwarze2018-12-081-9/+21
| | | | | because it changes the behaviour for empty input files; revert requested by naddy@ and sthen@
* As an extension to POSIX, for consistency with our behaviour forschwarze2018-12-071-2/+2
| | | | | | | | | | the "b" and "t" commands with a label, and for compatibility with GNU sed, also accept ";" followed by another command after "b" and "t" commands without a label: branch to the end of the script instead of erroring out. Parsing is unchanged. Missing feature reported by Lars dot Nooden at gmail dot com on bugs@. OK martijn@ millert@
* Add support for "-" as an input file for stdin as per POSIX.martijn2018-12-061-21/+9
| | | | | | | Simplify the code by allowing usage of stdin with the -i flag by pushing the result to stdout, so filters and in place editing can be combined. OK millert@
* Make sed's -i flag more compatible with what gsed does.martijn2018-11-144-28/+42
| | | | | | | | | | | - Reset the hold-space in between files - quit the editor as soon as a 'q' command is found - Make sure the temp-file is written back to the original file if we quit the editor temp-file not written back issue found by Time Chase. Lots of feedback from millert@ and schwarze@ OK millert@
* Improve consistency of the substitution command further.schwarze2018-08-141-20/+32
| | | | | | | | | | | | | | | | | | When the opening square bracket ('[') is abused as the delimiter, the regular expression contains a bracket expression, and the bracket expression contains another opening square bracket (sick! - i mean, sic!), then do not require escaping that innermost bracket and treat a preceding backslash as a literal backslash character, in accordance with POSIX: $ printf 'x[x\\x\n' | sed 's[\[[][R[g' xRx\x $ printf 'x[x\\x\n' | sed 's[\[\[][R[g' xRxRx While here, also make the implementation more readable and insert some comments. Joint work with martijn@ (started during g2k18) and OK martijn@.
* Make the output of the list command more sensible for the output device.martijn2018-07-111-1/+5
| | | | | | | We now output $COLUMNS - 8 characters of the string and a newline. This is similar to the behaviour in ed(1). Discussed with and OK schwarze@
* Rephrase the wording on the replacement string of the substitute command.martijn2018-07-111-9/+13
| | | | | | | | Cover more cases with less wording. Joint work with schwarze@ OK millert@
* Disentangle the "SED ADDRESSES", "SED REGULAR EXPRESSIONS",schwarze2018-07-101-19/+16
| | | | | | and "s/// command" sections and clarify what an escaped delimiter does inside regular expressions and inside character classes. Joint work with martijn@, no objection from jmc@.
* When using '[' as the delimiter in sed(1) s/// (don't do that, of course)schwarze2018-07-091-3/+3
| | | | | | | | and then including '[' in the regular expression by prepending a backslash to it, remove the backslash before feeding the RE to the RE engine, just like we already do it for other special characters like .^$*+?{(|. This makes sed 's[\[xy][...[' treat the xy thingy as a char class. Joint work with martijn@, OK guenther@ martijn@
* Remove EXAMPLES section.martijn2017-12-191-30/+2
| | | | | | | | | | | | The example itself was taken directly from the POSIX specification by jmc@, who doesn't remember adding it. This example isn't very clear about what it actually does, so just remove it. If someone can come up with one or more examples that give a more clear introduction to the workings of sed feel free to send them in. Prompted by a diff by kshe59 <at> zoho <dot> eu OK jmc@
* Fix array index by signed char; from martijn@millert2017-12-131-4/+3
|
* Fix sign compare warnings; OK martijn@millert2017-12-134-20/+20
|
* Enable compiler warnings; OK martijn@millert2017-12-131-1/+2
|
* Fix 2 bugs introduced by previous.martijn2017-12-121-3/+3
| | | | | | Pointed out by kshe59 <at> zoho <dot> eu OK millert@
* Fix and change y command in the following ways:martijn2017-12-112-49/+78
| | | | | | | | | | | | | | | | | | - When 'n' is used as a delimiter escaping 'n' will remain a newline instead of becoming a 'n' character. This is how POSIX specifies how this should work. Other implementations tested also do this wrong. - '[' and maybe other characters are not special during the parsing of the y command and don't need to be matched or treated special in any way. - POSIX specifies that a backslash followed by anything other than the delimiter, 'n', and another backslash, as well as repeating characters in string1 are unspecified. Since the various implementations handle these situations in opposing ways choose to error out on them to prevent people falling into the pitfall of expecting identical behaviour on various implementations. Inspired by the sed.1 patch by kshe59 <at> zoho <dot> eu Feedback and OK millert@ Manpage bits OK jmc@
* Make the r command filename obligatory, similar to what FreeBSD and NetBSDmartijn2017-12-082-26/+12
| | | | | | | | | | do for several years. While here make corresponding error message for missing read and write file consistent between commands/flag, and shrink the the code of the w flag of the s command by making it use the same code as the w command. Prompted by a larger diff by kshe59 <at> zoho <dot> eu OK millert@
* Make the command formatting more consistent.martijn2017-12-071-9/+9
| | | | | | | s/with/width type-O fix while here. From kshe59 <at> zoho <dot> eu OK jmc@
* Apply stricter pledge rules if possible. These are based on the usage ofmartijn2017-08-013-7/+30
| | | | | | | | | | | the 'w' and 'r' functions and the 'w' flag to the 's' function. If non of the above is used and input is being read from stdin, we drop all the way down to stdio! Original inspiration by benno@. OK millert@
* remove some spacing; ok schwarzejmc2017-07-191-5/+2
|
* Remove unused-with-dead-store variable oldpsanl.tom2017-02-221-3/+1
| | | | | | From Daniel Cegielka - thanks ok jca@
* Nuke more whitespace caught in the headlights of "warning:"krw2017-01-211-6/+6
| | | | rectification.
* Split error() into error() and warning() so error() can be marked __dead tokrw2017-01-206-22/+29
| | | | | | appease gcc. ok procter@ deraadt@
* make it clear that the s/// numeric flag can containschwarze2016-10-261-5/+9
| | | | | more than one digit but cannot start with zero; feedback and OK jmc@, OK jca@, OK millert@ on an earlier version
* Fix an off by one error when no matches were found in a substitute.martijn2016-10-111-2/+2
| | | | | | By pfg@ from FreeBSD OK millert@ and otto@
* make several program to use "chown" promise.semarie2016-07-141-2/+2
| | | | | | | | | | | | | | | | it allows chown(2) call to change the user or group on a file. - usr.bin/compress : aka gzip - usr.bin/mg : open a file for writing - usr.bin/sed : inplace editing - usr.bin/sort : if outfile equals one of the input files ok deraadt@ tb@ (and a reminder from Remi Locherer) warning: in order to use it, you must have a recent kernel with the new promise.
* Make sed use the new REG_STARTEND | REG_NOTBOL combination. This fixes a beginmartijn2016-05-301-17/+24
| | | | | | | | | | of word mismatch as reported by jsg@. Discussed with otto@ and others early on, earlier version tested in ports build by aja@ OK millert@ Few readability tweaks and OK schwarze@
* Switch (non-curses, non-ksh) programs that use COLUMNS to a single idiom.bentley2016-03-172-7/+18
| | | | | | | | Previously behaviors were all over the map. This changes them to use COLUMNS first, and either terminal width or a hardcoded value (typically 80) as appropriate. ok deraadt@; man bits ok jmc@
* Improve error message for sed -i by appending strerror(errno).tb2016-01-011-2/+2
| | | | | | From Michael Reed, thanks! ok deraadt@
* replace setbuf with setvbuf, from Frederic Nowaktedu2015-11-041-3/+3
|
* Tidy up error() levels: merge COMPILE and COMPILE2, and kill ERROR (unused)jca2015-10-262-9/+7
| | | | ok tobias@
* Use error(FATAL) instead of what was previously err(1,...)jca2015-10-261-4/+4
| | | | ok tobias@
* Rename err() to error() to prevent confusion with the stdlib function.mmcc2015-10-265-74/+74
| | | | Discussed with jca@.
* Write error message instead of duplicated file name on error.tobias2015-10-251-2/+2
| | | | ok deraadt
* normalize the ordering of tame requests (particularily, "rpath wpath cpath",deraadt2015-10-101-3/+3
| | | | | | | which i have put in that order). this is not important, but helps look for outliers which might be strange. it hints that "ioctl" should be reassessed in a few places, to see if "tty" is better; that "unix" may be used in some places where "route" could now work.
* Change all tame callers to namechange to pledge(2).deraadt2015-10-091-5/+5
|
* sed only works on files, so the obvious goal is to remove it's networkderaadt2015-10-031-1/+9
| | | | | | | access in case it is exploited. tame with "stdio wpath rpath cpath" seesms to covers all usage cases, except -i performs a fchmod() on the in-place file, so conditionally also needs "fattr". ok sthen
* fix eyesore whitespacejasper2015-07-201-6/+6
|
* figure out the linewidth at initialization, rather than latederaadt2015-07-192-20/+17
| | | | ok tedu miod
* Print strerror, not just the filename, if opening the inplace file fails.sthen2015-07-191-2/+3
| | | | ok jasper@
* various fixes; ok jasperjmc2015-07-182-16/+11
|
* add missing prototypejasper2015-07-171-1/+2
|
* 7 space indents??deraadt2015-07-171-24/+22
|
* add -i flag to sed to do in-place editing; mostly based on freebsdjasper2015-07-175-108/+276
| | | | feedback/ok deraadt@ millert@
* POSIX specifies that that multiple '!' characters preceding amillert2015-06-231-2/+2
| | | | | function should be treated as a single negation. From FreeBSD via Liviu Daia.
* Convert many atoi() calls to strtonum(), adding range checks and failurederaadt2015-04-181-4/+6
| | | | | handling along the way. Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert