so-dang-cool / dt

dt - duct tape for your unix pipes
https://dt.plumbing/
BSD 3-Clause "New" or "Revised" License
430 stars 12 forks source link

Add a way to opt-out of `read-lines` in pipes #36

Closed booniepepper closed 1 year ago

booniepepper commented 1 year ago

See thread started on Lobsters by @snej

https://lobste.rs/s/b8icdy/dt_duck_tape_for_your_unix_pipes#c_zx4lyn

There are some ideas in the thread... Right now I'm considering an interface something like:

dt <something> [ read-line   <code> ] loop

Where loop just performs some action until it dies. The broken pipe will signal dt that it's time to exit peacefully.

I pulled out my Thesaurus for this one. Other words for loop that were considered and rejected:

  1. forever -- Has some Too long, and also not semantically correct if the idea is to exit on EOF or broken pipe or a quit/exit within the quote
  2. repeat -- Semantically does not mean repeat many times. "Can you repeat that?" implies exactly one repetition, for example.
  3. cycle -- Kinda similar to loop. My Haskell experience makes me associate cycle with converting a finite list to a lazy infinite list. There are some similarities to loop even in etymology, but here I'm gonna prefer the shorter word that's more popular in compsci
  4. Some symbol -- No obvious and easy-to-type symbol IMO. I prefer to preserve symbol space for user definitions

booniepepper commented 1 year ago

Added the <something> as stream

booniepepper commented 1 year ago

Now possible in 1.2.0 with dt stream ...

A small example is available here: https://dt.plumbing/user-guide/tutorial/pipes-and-shebangs.html (Currently still a work in progress)