1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:07:45 +00:00

Utilities: Add more commands, addresses, spaces, cmdline parsing to sed

The initial version of sed implements only the `s` command (given on the
command line) applied to all lines of the input file. While this is
probably the most common scenario that people use sed with in the wild,
it's limited in several ways:

 * `s` is only one of the many commands that sed is meant to implement.
 * Commands may take one or two addresses that limits its applicability
   to input lines.
 * Commands in general operate over the "pattern" and "hold" spaces
   rather than blindly over input lines.
 * Command line parameters include specifying a script file, and
   optionally input file(s) and/or a script to execute.

This commit implements a big portion of these missing features:

 * It adds support for parsing *almost* all commands and their
   arguments.
 * It also implements the execution of a big portion of the commands.
 * It adds support for parsing the optional addresses that prefix a
   command, and enables/disables commands based on these address ranges.
 * It implements the pattern and hold spaces, which are the source of
   input/output for most of the commands.
 * It improves the command line argument handling to receive a script
   file, potentially multiple execution scripts, and optional input
   files.

Some know missing functionality:

 * The `{` and `}` commands are not supported yet.
 * Pattern-based addresses are not supported yet.
 * Labels and branches are parsed, but not supported at runtime.
This commit is contained in:
Rodrigo Tobar 2021-10-24 11:32:56 +08:00 committed by Andrew Kaster
parent 5a8373c6b9
commit 41fa1a1461
2 changed files with 856 additions and 106 deletions

View file

@ -3,7 +3,7 @@ list(APPEND SPECIAL_TARGETS test install)
list(APPEND REQUIRED_TARGETS list(APPEND REQUIRED_TARGETS
arp base64 basename cat chmod chown clear comm cp cut date dd df diff dirname dmesg du echo env expr false arp base64 basename cat chmod chown clear comm cp cut date dd df diff dirname dmesg du echo env expr false
file find grep groups head host hostname id ifconfig kill killall ln logout ls mkdir mount mv nproc file find grep groups head host hostname id ifconfig kill killall ln logout ls mkdir mount mv nproc
pgrep pidof ping pkill pmap ps readlink realpath reboot rm rmdir route seq shutdown sleep sort stat stty su tail test pgrep pidof ping pkill pmap ps readlink realpath reboot rm rmdir sed route seq shutdown sleep sort stat stty su tail test
touch tr true umount uname uniq uptime w wc which whoami xargs yes touch tr true umount uname uniq uptime w wc which whoami xargs yes
) )
list(APPEND RECOMMENDED_TARGETS list(APPEND RECOMMENDED_TARGETS

File diff suppressed because it is too large Load diff