Skip to content

0.3.0

Latest

Choose a tag to compare

@github-actions github-actions released this 18 Oct 08:53

Rust sed 0.3.0 Release:

We are happy to announce the release of Rust sed 0.3.0.

The GNU-specific commands F, W and R are now implemented. Most of the remaining work went into the details scripts actually depend on: how n and Q end a cycle, when text queued by a, r and R is written or dropped, how l shows an empty pattern space, and how -i treats each file as a separate input.

Diagnostics were reworked as well: errors now follow the modern style used by Rust Coreutils, point at the right position in the script (even at its very end), and report where an unmatched { was opened.

At a terminal, the offending character is underlined in the script. Here is the same typo with both implementations:

GNU sed 4.9:

$ sed 's/foo/bar/gq' file.txt
sed: -e expression #1, char 12: unknown option to `s'

Rust sed 0.3.0:

$ sed 's/Normandie/Bretagne/gq' fromages.txt
sed: <script argument 1>:1:23: error: invalid substitute flag: 'q'
   ╭─[ <script argument 1>:1:23 ]
   │
 1 │ s/Normandie/Bretagne/gq
   │                       ─
───╯

Test in the playground: https://uutils.org/playground/?cmd=sed+%27s%2FNormandie%2FBretagne%2Fgq%27+fromages.txt

GNU sed reports an unknown option somewhere in the s command. We name the faulty flag, give the line and column, and show where it is. Pipes keep the single-line message; set UUTILS_DIAG=always to force the full output.

We are now at 18 passing, 39 failing, 0 errors on the GNU sed test suite.


GNU Test Suite Compatibility:

Result 0.2.0 0.3.0 Change 0.2.0 to 0.3.0 % Total 0.2.0 % Total 0.3.0 % Change 0.2.0 to 0.3.0
Pass 14 18 +4 21.54% 27.69% +6.15%
Skip 10 8 -2 15.38% 12.31% -3.07%
Fail 41 39 -2 63.08% 60.00% -3.08%
Error 0 0 0 0% 0% 0%
Total 65 65 0

Note: four tests now pass: cmd-R, distrib, inplace-hold and stdin-prog. The CI now also generates the multibyte locales the suite needs, so title-case and utf8-ru are no longer skipped; they run and fail for now, which is why the failure count only drops by two. Counting only the tests that actually run, we are at 18/57 (31.6%), up from 14/55 (25.5%). We are comparing against GNU sed from its upstream repository.


GNU testsuite evolution


Highlights:

  • New GNU Commands

    • F: print the current input file name
    • W: write the first line of the pattern space to a file
    • R: read one line from a file and queue it for output
  • GNU Compatibility

    • n continues with the next command instead of starting a new cycle
    • Q discards text queued by a, r and R, and no longer writes a missing final newline
    • Appended text, R text and e output are written at the same point as in GNU sed
    • l shows an empty pattern space as $, even without a trailing newline; Unicode listing matches GNU sed
    • -i treats each file as a separate input, and takes its suffix only when attached (-i.bak), as GNU sed does
    • A range whose numeric first address was already passed now starts, as GNU sed does
  • Diagnostics

    • Error messages use the modern style of Rust Coreutils
    • The script position is kept for errors at the end of the script
    • An unmatched { reports where it was opened
    • An unterminated s or y command is reported instead of aborting
    • At a terminal, the offending character is underlined in the script (see the example above)
  • Robustness

    • Panics and zero steps fixed in ~ and , addresses
  • Performance

    • Literal regex needles are stored in an Arc, avoiding copies
  • Distribution

    • cargo binstall support
    • Extensions and incompatibilities are now documented in docs/src/extensions.md
  • Contributions: This release landed 57 pull requests from 5 new contributors


Call to Action:

Sponsor us on GitHub to accelerate development: github.com/sponsors/uutils

What's Changed

New Commands

GNU Compatibility

  • Make Unicode listing GNU-sed compatible by @dspinellis in #537
  • in-place editing: treat each file as a separate input by @SichenLiang in #569
  • sed: take the -i suffix only when attached, as GNU sed does by @DePasqualeOrg in #583
  • sed: continue with the next command after n instead of starting a new cycle by @DePasqualeOrg in #592
  • sed: show an empty pattern space as $ in l, even without a newline by @DePasqualeOrg in #595
  • sed: discard text queued by a, r and R on Q, as GNU sed does by @DePasqualeOrg in #594
  • sed: write appended text, R text and e output as GNU sed does by @DePasqualeOrg in #589
  • sed: start a range whose numeric first address was already passed by @sap1110 in #581
  • sed: don't write a missing final newline on Q, as GNU sed does by @DePasqualeOrg in #597

Diagnostics & Robustness

  • sed: fix panics and zero steps in ~ and , addresses by @sylvestre in #578
  • sed: keep script position for errors at end of script by @sylvestre in #579
  • sed: implement modern diagnostic like coreutils by @sylvestre in #576
  • compiler: report an unterminated s or y command instead of aborting by @SichenLiang in #571
  • sed: report where an unmatched { was opened by @sylvestre in #580

Performance

Testing

Code Quality & Cleanup

  • clippy: fix warnings from assert_is_empty lint by @cakebaker in #588

CI & Build

  • Add binstall support by @sylvestre in #520
  • ci: generate multibyte locales for the GNU testsuite by @sylvestre in #539
  • ci: use an absolute LLVM_PROFILE_FILE path so coverage includes the sed binary by @DePasqualeOrg in #591
  • ci.yml: avoid full git clone (--depth=1) by @oech3 in #600

Documentation

  • docs: move extensions and incompatibilities to docs/src/extensions.md by @sylvestre in #575

Dependency Updates

Version Management

New Contributors

Download sed 0.3.0

File Platform Checksum
sed-aarch64-apple-darwin.tar.xz Apple Silicon macOS checksum
sed-x86_64-apple-darwin.tar.xz Intel macOS checksum
sed-x86_64-pc-windows-msvc.zip x64 Windows checksum
sed-aarch64-unknown-linux-gnu.tar.xz ARM64 Linux checksum
sed-x86_64-unknown-linux-gnu.tar.xz x64 Linux checksum
sed-x86_64-unknown-linux-musl.tar.xz x64 MUSL Linux checksum

Full Changelog: 0.2.0...0.3.0