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

Request for command line flag to control line buffering #555

Closed
unphased opened this issue May 27, 2015 · 6 comments
Closed

Request for command line flag to control line buffering #555

unphased opened this issue May 27, 2015 · 6 comments

Comments

@unphased
Copy link

Similar to BSD Grep's --line-buffering flag.

For example I want to use ack to do a regex (which needs ack because regex has lookbehind) in a pipe with fswatch, the events trigger single lines of input over the pipe, so I'd like an immediate response, which buffers only lines.

@petdance
Copy link
Collaborator

I think you mean you want to disable line buffering, right?

@unphased
Copy link
Author

Does it already do line buffering by default?

Edit: Wow, looks like it does! Okay!

Yes, then someone may want non-line-buffering as a feature. For performance. Or something. Hey Ack is supposed to be faster than grep, somehow, right?

Sorry about not properly testing. I thought i tested it right, but I didn't.

@petdance
Copy link
Collaborator

I'm confused when you say "I'd like an immediate response, which requires line buffering". "immediate response" would require a given program to not have any line buffering. An immediate response would mean that there is no buffer in the program for holding output.

@unphased unphased changed the title Request for Line buffering feature Request for command line flag to control line buffering May 27, 2015
@unphased
Copy link
Author

Yes you are right, I edited a few things. Does it clarify? I'm 100% satisfied now because turns out ack already by default does not do buffering. Which is what I wanted to begin with.

Feel free to close, i'm leaving it because it could be a cool enhancement to add configurability w.r.t. buffering (but like i said I don't care much at this point).

What i meant by line buffering is simply to not engage in 4k-buffering (or page buffering). Perhaps in implementation that actually means no buffering, which is fine. I do believe a distinction does exist between completely raw no buffering and line-buffering (where a real buffer exists to hold data until a newline is seen), however. (the former not being advisable for performance reasons)

@petdance
Copy link
Collaborator

ack is written in Perl, and Perl by default does have output buffering on. We do have the --flush option to turn that off:

  --flush                       Flush output immediately, even when ack is used
                                non-interactively (when output goes to a pipe or
                                file).

How did you conclude that ack does not do buffering by default?

@unphased
Copy link
Author

I see. I concluded as I did because the behavior between grep and ack is different. When used with a pipe, grep continues buffering, but ack is smart and figures out to use --flush in that situation.

Since you just showed me the flag, this answers the question. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants