PROPHET/OS
NAME
sed: a line in, a line out, and what happened in between said out loud
SYNOPSIS
sed [-n] [-E] [-streng] [-e script] [script] sed selbsttest
DESCRIPTION
A line in, a line out, and what happened in between said out loud.
addresses N (that line), $ (the last), /pattern/ (every line that matches) commands s/pattern/replacement/[g][p], p, d, q groups \1 to \9 and & in the replacement escapes \n \t \\ in the replacement -n only what p prints -E, -r taken for the hand, the language has groups anyway -streng a substitution that never fired ends with 1
A bracket is a group here, and a literal bracket is \(. That is the one place where this program reads a pattern differently from grep, which takes a bracket as the character it is. The rest of the language stands in the head of lib/text/pattern.c.
What it does better than the original
- **A script it does not understand is refused**, with the character position and the reason. sed 's/a/b' says where the delimiter is missing instead of "unterminated". - **A substitution that never fired is said** on err. That is the commonest bug in a build: the script runs, the exit code is zero and nothing changed. With -streng it ends with 1. - **A line longer than the buffer is an error, not a cut.** A cut line is a wrong result that looks like a right one. - **A group that repeats is refused** (s/(a)*/b/) instead of being read as something else.
sed selbsttest drives twelve cases: the six scripts the build itself uses, the one and the all of g, the three ways a script is no script, and that a substitution which cannot fire counts zero.
EXAMPLE
$ sed --help sed [-n] [-E] [-streng] [-e script] [script] selbsttest drives its own twelve cases s/pattern/replacement/[g][p], p, d, q, with an address -n only what p prints -streng a substitution that never fired ends with 1