Perhaps sed was not meant to be a programming language, but does have a limited
form of flow control. Adding to sed some features common in other languages will
facilitate solving some problems and perhaps make sed more readable. Here are
features I want to see in an improved sed.
global macros - sed supports macros within a regular expression and within a
substitute command. These are \1 through \9 and are defined by previously placed
pairs of escaped parentheses. A formal global macro definition will reduce the size and increase the readability of large sed scripts.
global integer variables will facilitate counting and enumeration of replacements
within the actual substitution.
a way to compare the "hold" and "pattern" spaces and then "branch" equal and not equal
the ability to branch on substitution or on no substitution for the substitute
the ability to branch on match or branch on no match for an "address" (which may
be a regular expression.) This command immediately follows a pair of
kx Software Aesthetics
This web site is best viewed with FireFox, Chrome or Safari.