An error found once the script is exhausted, like an unterminated command, was reported as ":0:N" with no input name. Keep the last input name and line number so the error points at the right line.
sed
Rust reimplementation of the sed utility with some GNU sed, FreeBSD sed, and other extensions.
Status
At this state sed implements all POSIX features and can run correctly the three complex scripts of its integration tests: hanoi.sed (solves the Towers of Hanoi puzzle), mandelbrot.sed, (draws the Mandelbrot set) and math.sed (implements an arbitrary precision integer math calculator).
The performance of this Rust implementation is now better than the GNU and FreeBSD implementations for most benchmarked cases.
Further work aims to:
- improve GNU sed compatibility, especially on the regular expression front,
- implement more GNU extensions, and
- improve performance where possible.
Installation and Use
We provide a Linux x86_64 binary archive from the main branch at https://github.com/uutils/sed/releases/tag/latest-commit .
If you have cargo-binstall, the released binaries can be installed directly with:
cargo binstall sed
For other platforms, ensure you have Rust installed on your system. You can install Rust through rustup.
Clone the repository and build the project using Cargo:
git clone https://github.com/uutils/sed.git
cd sed
cargo build --release
cargo run --release
The binary is named sed in target/release/sed.
You can also try sed on the web
through the uutils Playground
by clicking on the Load sed button.
Testing
GNU sed Compatibility Testing
Test compatibility against GNU sed by running the upstream testsuite shell scripts with a lightweight gnulib test-framework shim:
# Clone GNU sed testsuite (one time setup)
git clone https://github.com/mirror/sed.git ../gnu.sed
# Run compatibility tests
./util/run-gnu-testsuite.sh
# Verbose mode shows failure details
./util/run-gnu-testsuite.sh -v
# Generate JSON results for CI
./util/run-gnu-testsuite.sh --json-output results.json
The harness executes each .sh test from the GNU sed testsuite directly, injecting
our Rust sed binary via PATH and providing shim implementations of the gnulib test
framework functions (compare_, returns_, skip_, etc.).
Unit Tests
cargo test
Extensions and incompatibilities
The GNU, BSD and new extensions sed supports, and where it differs from GNU sed, are listed in docs/src/extensions.md.
GNU test suite compatibility
Below is the evolution of how many GNU tests uutils passes.
License
sed is licensed under the MIT License - see the LICENSE file for details