This is the mail archive of the cygwin-talk mailing list for the cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: My pipe flushes late


Brian Dessent wrote:
Robert Schmidt wrote:
Oh, I missed that qualifier.  So, what you really mean is that sed is a
total red herring as you aren't actually using sed but something else
entirely in the real application?  Anyway, if you absolutely must have a
d2u that is line buffered instead of full buffered then you can use

perl -pe 'BEGIN { $| = 1; } s,\r$,,;' | whatever_the_actual_thing_is

Thanks! In the meantime, I've discovered that the reason for d2u (the read builtin freezing on single 0x0D characters) seems to be gone in cygwin, so I can simplify my script.


For completeness, my real script is:

#!/bin/bash
# read stalls on 0x0d in input, d2u fixes that, but introduces buffering
d2u | while true
do
	read -r || exit
	echo `date +"%F %T"` "$REPLY"
done

... where d2u can probably be removed now.
It's used to timestamp output from various services, some of which output DOS line endings. E.g. my-service.sh | prefix-time.sh.


If there was a way to execute a command (date, in my case) from within the sed replacement section, I'd be home free with a single sed process instead of a chunky bash process lurking about.


Robert



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]