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
paragraph input mode ($/="") prevents readline from returning latest paragraph from pipe #16902
Comments
From rob.navarro@appdynamics.comCreated by rob.navarro@appdynamics.comSubject: paragraph input mode ($/="") prevents readline from returning This is a bug report for perl from rob.navarro@appdynamics.com, ----------------------------------------------------------------- The very last "paragraph" written into a pipe is not found by readline [terminal output follows] $ perl -MPOSIX -e 'select((select( STDOUT ), $|=1)[0]);for (1..3) { print # Notice that in above the pipe reader's timestamp matches the timestamp $ perl -MPOSIX -e 'select((select( STDOUT ), $|=1)[0]);for (1..3) { print <## 2019-03-22T15:22:44 ## >## 2019-03-22T15:22:44 2 <## 2019-03-22T15:22:50 ## >## 2019-03-22T15:22:44 3 <## 2019-03-22T15:22:50 ## >## 2019-03-22T15:22:50 1 <## 2019-03-22T15:22:50 ## >## 2019-03-22T15:22:50 2 <## 2019-03-22T15:22:55 ## >## 2019-03-22T15:22:50 3 <## 2019-03-22T15:22:55 ## >## 2019-03-22T15:22:55 1 <## 2019-03-22T15:22:55 ## >## 2019-03-22T15:22:55 2 <## 2019-03-22T15:23:00 ## >## 2019-03-22T15:22:55 3 # Notice that only two of the three paragraphs are output before 5 second [end of terminal output] This issue seems to occur regardless of how big or small each paragraph is Also a problem on v5.18.2 Perl Info
|
From @jkeenanOn Fri, 22 Mar 2019 22:48:18 GMT, rob.navarro@appdynamics.com wrote:
Confirmed in perl-5.28.0. -- |
The RT System itself - Status changed from 'new' to 'open' |
From @tonycozOn Fri, 22 Mar 2019 15:48:18 -0700, rob.navarro@appdynamics.com wrote:
This happens because paragraph mode tries to consume *all* of the newlines following the paragraph. So in your case, readline() is blocking on trying to read that next character to check if it's a newline. I expect you'd be better off using $/ = "\n\n" Tony |
From rob.navarro@appdynamics.comOn Sun, 24 Mar 2019 21:50:29 -0700, tonyc wrote:
Thank you for the clear response (tried responding to email but test did not show up here). |
From rob.navarro@appdynamics.comThank you for the clear response. On Sun, Mar 24, 2019 at 9:50 PM Tony Cook via RT <perlbug-followup@perl.org>
-- *AppDynamics* <http://www.appdynamics.com/appsphere>AppDynamics, Inc. is a Delaware |
From @tonycozOn Wed, 27 Mar 2019 21:42:21 -0700, rob.navarro@appdynamics.com wrote:
The problem with not consuming the extra newlines is the next read from the stream might not be from readline, existing code might expect paragraph mode to consume them and then switch $/ = "\n" to consume a line at a time, or use read(). It would be a backwardly incompatible change. Tony |
From rob.navarro@appdynamics.comThank you for your response. By analogy with the single newline separate case, I now understand your point and agree. When each row is returned it is also assumed to have *already* consumed the 'newline' separator that comes next. Hence my observation of delayed readline (which I assumed was a bug) is a simple consequence of: therefore paragraph mode should always hold on to an input until it sees either EOF or the next non-delimiter - which makes it rubbish for pipe processing ! Please go ahead and close this issue as a non-bug (surprising consequence). On Sun, 31 Mar 2019 16:34:54 -0700, tonyc wrote:
|
Migrated from rt.perl.org#133949 (status was 'open')
Searchable as RT133949$
The text was updated successfully, but these errors were encountered: