Commit Graph

4 Commits

Author SHA1 Message Date
Kyle Evans
6e816d8711 sed: process \r, \n, and \t
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
2019-12-10 19:16:00 +00:00
Mark Johnston
b480502648 sed: Fix -i option behavior with 'q' command.
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
2018-08-29 17:09:03 +00:00
Enji Cooper
e58164041c Don't expect :inplace_symlink_src to fail anymore (post-r313277)
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
2017-02-07 18:23:44 +00:00
Enji Cooper
68730a222d Add testcases for -i with hardlinks and symlinks
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
2017-01-20 07:11:21 +00:00