Just Don't. Unix-style text stream processing was super cool in 80s-90s but is born tech-debt today.

what do you do instead?

If you do "object manipulation" e.g. columns/records/objects etc then at least Powershell offers some sanity.

Shameless plug but this is what I wrote murex for. Murex is a "UNIX" shell that's keeps enough similarities with POSIX that you can use it like a Bash REPL with (hopefully) minimal disruption but it breaks from POSIX compatibility where it makes sense. And one significant area it does break compatibility is how it handles structured data formats like JSON, S-Expressions, CSV's, and other tabulated data (to name a few).

It's designed from the ground up to support object manipulation while still retaining compatibility with the UNIX pipeline.

I do this by building a suite of builtin tools that are aware of structured data files (primarily because that information is passed down the pipeline as a data-type) but it still breaks into normal pipeline when forking an external executable.

https://github.com/lmorg/murex