From 0f378d8cb7ab1d265d2cd2569edfea02eaa11f82 Mon Sep 17 00:00:00 2001 From: SFG545 Date: Tue, 9 Jun 2026 00:30:16 -0500 Subject: [PATCH] bump version to 1.0.0 and add man page for sed --- man/sed.1 | 270 ++++++++++++++++++++++++++++++++++++++++++++++++++++ meson.build | 4 +- 2 files changed, 273 insertions(+), 1 deletion(-) create mode 100644 man/sed.1 diff --git a/man/sed.1 b/man/sed.1 new file mode 100644 index 0000000..ad30e8d --- /dev/null +++ b/man/sed.1 @@ -0,0 +1,270 @@ +.TH SED 1 "June 2026" "Sed++ 1.0.0" "User Commands" +.SH NAME +sed \- stream editor for filtering and transforming text +.SH SYNOPSIS +.B sed +.RI [ OPTION ]... +.RI { script-only-if-no-other-script } +.RI [ input-file ]... +.SH DESCRIPTION +.B sed +reads text from the named input files, or standard input if no files are named, +and applies a compiled editing script to each input record. +By default each pattern space is printed after the script finishes for that +cycle. +.PP +Sed++ is a native C++ implementation intended to behave like GNU +.BR sed +for ordinary command-line use and for the GNU sed 4.10 behavioral test suite. +It supports standard sed pattern space, hold space, addresses, address ranges, +substitutions, transliteration, branching, file reads and writes, shell +execution commands, NUL-delimited input, and in-place editing. +.SH OPTIONS +.TP +.BR \-n ", " \-\-quiet ", " \-\-silent +Suppress automatic printing of pattern space. Output is produced only by +commands such as +.BR p , +.BR P , +.BR l , +.BR a , +.BR i , +.BR c , +.BR r , +.BR R , +.BR w , +and +.BR = . +.TP +.BI \-e " script" +.TQ +.BI \-\-expression= script +Add +.I script +to the commands to be executed. Multiple +.B \-e +and +.B \-f +options are evaluated in command-line order. +.TP +.BI \-f " script-file" +.TQ +.BI \-\-file= script-file +Add commands read from +.I script-file +to the program. A file name of +.B \- +reads the script from standard input. +.TP +.BR \-E ", " \-r ", " \-\-regexp-extended +Use extended regular expressions. +.TP +.BI \-i [ suffix ] +.TQ +.BI \-\-in-place[= suffix ] +Edit files in place. If +.I suffix +is supplied, create a backup before replacing the file. If the suffix contains +.BR * , +each star is replaced by the edited file name; otherwise the suffix is appended +to the file name. +.TP +.BI \-l " N" +Set the default line-wrap width used by the +.B l +command. The attached form +.BI \-l N +is also accepted. +.TP +.BR \-z ", " \-\-null-data +Use NUL bytes rather than newlines as input record separators. +.TP +.BR \-s ", " \-\-separate +Treat input files separately for line numbering and the +.B $ +address. +.TP +.BR \-u ", " \-\-unbuffered +Enable unbuffered-style behavior for supported streaming cases. +.TP +.BR \-b +Accepted for GNU sed compatibility. On Unix streams are already binary, so this +option has no effect. +.TP +.BR \-\-follow-symlinks +When editing in place, follow symlinks and edit the final target rather than +replacing the symlink itself. +.TP +.BR \-\-sandbox +Request GNU-compatible sandbox behavior. Shell execution through +.B e +commands and substitution +.B e +flags is disabled at runtime; selected filesystem-access diagnostics are +reported for GNU sed compatibility. +.TP +.BR \-\-posix +Enable stricter POSIX behavior and reject selected GNU extensions. +.TP +.BR \-\-debug +Print a minimal compiled-program debug view before execution. +.TP +.BR \-\-help +Print a short usage summary and exit. +.TP +.BR \-\-version +Print the Sed++ version and exit. +.SH SCRIPT LANGUAGE +A sed script is a sequence of commands. A command has the form: +.PP +.RS +.IR [ address [ , address ]] [ ! ] command [ arguments ] +.RE +.PP +Addresses select the input cycles where a command applies. Supported addresses +include numeric line addresses, +.B $ +for the last input record, regular-expression addresses such as +.BI / regexp / , +GNU periodic addresses such as +.IR first ~ step , +and GNU range endings +.BI + N +and +.BI ~ N . +The +.B ! +modifier negates address selection. +.PP +Regular expressions use POSIX basic syntax unless +.B \-E +or +.B \-r +is supplied. Empty regular expressions reuse the most recently compiled +non-empty regular expression. +.SH COMMANDS +.TP +.BI s/ regexp / replacement / flags +Replace text matched by +.I regexp +with +.IR replacement . +Supported flags include +.B g +for global replacement, +.B p +to print after a successful substitution, +.B e +to execute the result as a shell command, +.B i +or +.B I +for case-insensitive matching, +.B m +or +.B M +for multiline matching, numeric occurrence selection, and +.BI w " file" +to write successful replacements. +.TP +.BI y/ source / dest / +Transliterate characters from +.I source +to corresponding characters in +.IR dest . +.TP +.BR p ", " P +Print the whole pattern space, or only the portion through the first embedded +newline. +.TP +.BR d ", " D +Delete the pattern space and start the next cycle, or delete through the first +embedded newline and restart the script with the remaining pattern space. +.TP +.BR n ", " N +Read the next input record, replacing or appending to pattern space. +.TP +.BR h ", " H ", " g ", " G ", " x +Copy, append, restore, append from, or exchange the hold space and pattern +space. +.TP +.BR a ", " i ", " c +Append, insert, or replace text. +.TP +.BI r " file" +.TQ +.BI R " file" +Append a whole file, or append the next line from a file. +.TP +.BI w " file" +.TQ +.BI W " file" +Write the whole pattern space, or only the portion through the first embedded +newline, to a file. +.TP +.BI e " command" +Execute a shell command. With no command argument, execute the current pattern +space and replace it with the command output. +.TP +.BR b ", " t ", " T ", " : label +Branch unconditionally, branch after a successful substitution, branch after no +successful substitution, or define a label. +.TP +.BR q ", " Q +Quit, optionally with an exit status. The +.B q +command prints the current pattern space first unless automatic printing is +suppressed; +.B Q +quits without printing it. +.TP +.BR l +List pattern space with escaped non-printing characters. +.TP +.BR = ", " F ", " z +Print the current line number, print the current file name, or clear pattern +space. +.TP +.BR { ", " } +Group commands. +.SH ENVIRONMENT +.TP +.B POSIXLY_CORRECT +Enables POSIX runtime behavior. +.TP +.B COLS +Used as the default wrap width for the +.B l +command when no line length is specified. +.SH EXIT STATUS +.TP +.B 0 +Successful execution. +.TP +.B 1 +Script compilation or runtime command failure. +.TP +.B 4 +Usage, input, output, or in-place editing failure. +.SH EXAMPLES +.TP +Print only lines 10 through 20: +.EX +sed -n '10,20p' file.txt +.EE +.TP +Replace all occurrences of a word in place, keeping backups: +.EX +sed -i.bak 's/old/new/g' file.txt +.EE +.TP +Use NUL-delimited records: +.EX +find . -print0 | sed -z 's#^./##' +.EE +.SH SEE ALSO +.BR awk (1), +.BR grep (1), +.BR regex (7) +.SH AUTHORS +Sed++ is maintained as part of the sfgos_revamp sed project. diff --git a/meson.build b/meson.build index 132edae..be418c8 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project( 'sedpp', 'cpp', - version: '0.1.0', + version: '1.0.0', default_options: [ 'cpp_std=c++20', 'warning_level=3', @@ -11,6 +11,8 @@ project( subdir('sed') +install_man('man/sed.1') + # Run the upstream GNU sed 4.10 behavioral suite against the local executable. # The wrapper downloads/builds GNU sed only to reuse its tests. gnu_sed_tests = find_program('scripts/run-gnu-sed-tests.sh')