Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow STDIN input #100

Open
vtronko opened this issue Sep 16, 2020 · 10 comments
Open

Follow STDIN input #100

vtronko opened this issue Sep 16, 2020 · 10 comments
Labels
C-enhancement Category: New feature or request

Comments

@vtronko
Copy link

vtronko commented Sep 16, 2020

I expect sd to follow the STDIN, as it would do in sed.
For example, I expect
journalctl -u dnscrypt-proxy.service -f | sd machinename home
to give consistent live output, as
journalctl -u dnscrypt-proxy.service -f | sed '/s/machinename/home/
would. Instead, it just waits for EOF, due to
handle.read_to_end(&mut buffer)?;

I'd suggest to use terminal buffering mode (flush buffer at newline), but that'd break multiline replacement.

This is an important usecase for log inspection routines with custom formatting.

@jnnkB
Copy link

jnnkB commented Mar 27, 2021

This would be really cool and could perhaps be archived by adding an line by line mode.

@sebastianblunt
Copy link

Easy to replicate with (echo a && sleep 5 && echo a) | sd a b. Probably related to #96

@varenc
Copy link

varenc commented Nov 17, 2022

I'm also struggling with this issue. Usually the stdbuf or the unbuffer tools are able to force programs to be line buffered, but no luck using those for sd. (stdbuf relies on tweaking the version of libc that's loaded, but since sd is written in rust, I assume that's why it doesn't work).

When I want to view the live output of a series of pipes, I sadly have to switch back to using sed even though I vastly prefer sd. GNU Sed has an --unbuffered flag which instantly accomplishes this.

@intelfx
Copy link

intelfx commented Jan 31, 2023

This is not related to buffering. sd seems to work by reading whole stdin until EOF into memory prior to performing any work on it. Thus, sd it is not really a sed alternative as it is not "streaming".

@brunetton
Copy link

Same here (super useful comment, I know)

@vtronko
Copy link
Author

vtronko commented Mar 14, 2023

This is not related to buffering. sd seems to work by reading whole stdin until EOF into memory prior to performing any work on it. Thus, sd it is not really a sed alternative as it is not "streaming".

Exactly why this is related to line-based buffering, the lack thereof…

@vtronko
Copy link
Author

vtronko commented Mar 14, 2023

For what it's worth, I created a fix which works, but I need to create more tests for it. I will publish the code later.

vtronko added a commit to vtronko/sd that referenced this issue Mar 14, 2023
vtronko added a commit to vtronko/sd that referenced this issue Mar 14, 2023
vtronko added a commit to vtronko/sd that referenced this issue Mar 14, 2023
@CosmicHorrorDev CosmicHorrorDev added the M-needs triage Meta: Maintainer label me! label May 17, 2023
@borestad
Copy link

borestad commented Sep 1, 2023

Any progress on this? 🙂

@corneliusroemer
Copy link

It looks like @vtronko's commits on his fork work - I tested them locally. They need to be rebased onto the current main but otherwise looks good. @chmln can you have a look at: vtronko@fcd59ac?

@CosmicHorrorDev
Copy link
Collaborator

CosmicHorrorDev commented Dec 23, 2023

I know @dev-ardi has interest in making this change. The limiting factor has been maintainer time at the moment (aka I've been very very busy)

corneliusroemer pushed a commit to corneliusroemer/sd that referenced this issue Dec 23, 2023
corneliusroemer pushed a commit to corneliusroemer/sd that referenced this issue Dec 23, 2023
corneliusroemer pushed a commit to corneliusroemer/sd that referenced this issue Dec 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: New feature or request
Projects
None yet
Development

No branches or pull requests

9 participants