Jasper Lievisse Adriaanse <jas...@openbsd.org> writes:

> Hi,
>
> Here's a diff to add the '-i' flag to sed to do inplace edits. It's mostly
> from FreeBSD with some adjustments to prevent a race with unlink() and fopen()
> during the tempfile creation.
>
> It's been tested in a full ports bulk (thanks aja), and went through a build
> of base and xenocara.
> Regress tests will also be added for this.
>
> This diff is already OK millert@. Any more OKs?

I'm fine with the direction, this obviously helps the ports tree.

I haven't reviewed the code, but here's a small nit,

> Index: sed.1
> ===================================================================
> RCS file: /cvs/src/usr.bin/sed/sed.1,v
> retrieving revision 1.44
> diff -u -p -r1.44 sed.1
> --- sed.1     22 Oct 2014 23:23:22 -0000      1.44
> +++ sed.1     16 Jul 2015 19:15:14 -0000
> @@ -47,6 +47,7 @@
>  .Op Fl aEnru
>  .Op Fl e Ar command
>  .Op Fl f Ar command_file
> +.Op Fl i Op Ar extension

should be something like

+.Op Fl i Ns Op Ar extension

since there should be no whitespace between -i and the optional
suffix.

>  .Op Ar
>  .Sh DESCRIPTION
>  The
> @@ -94,6 +95,16 @@ Append the editing commands found in the
>  .Ar command_file
>  to the list of commands.
>  The editing commands should each be listed on a separate line.
> +.It Fl i Ar extension

Same here.

> +Edit files in-place, saving backups with the specified
> +.Ar extension .
> +If a zero-length
> +.Ar extension
> +is given, no backup will be saved.
> +It is not recommended to give a zero-length
> +.Ar extension
> +when in-place editing files, as you risk corruption or partial content
> +in situations where disk space is exhausted, etc.
>  .It Fl r
>  An alias for
>  .Fl E ,
> @@ -510,6 +521,12 @@ command,
>  squeezing excess empty lines from standard input:
>  .Bd -literal -offset indent
>  $ sed -n '
> +.Pp
> +The
> +.Fl i
> +option is a non-standard
> +.Fx
> +extension and may not be available on other operating systems.
>  # Write non-empty lines.
>  /./ {
>      p
> @@ -543,7 +560,7 @@ utility is compliant with the
>  specification.
>  .Pp
>  The flags
> -.Op Fl aEru
> +.Op Fl aEiru
>  are extensions to that specification.
>  .Pp
>  The use of newlines to separate multiple commands on the command line
>

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to