public inbox for cygwin-talk@cygwin.com
 help / color / mirror / Atom feed
From: Robert Schmidt <rschm@broadpark.no>
To: cygwin-talk@cygwin.com
Subject: Re: My pipe flushes late
Date: Wed, 20 Aug 2008 13:15:00 -0000	[thread overview]
Message-ID: <g8h5bl$vsd$1@ger.gmane.org> (raw)
In-Reply-To: <48AC108E.1D666660@dessent.net>

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

  reply	other threads:[~2008-08-20 13:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-20 11:55 Robert Schmidt
2008-08-20 12:07 ` Eric Blake
2008-08-20 13:20   ` Robert Schmidt
2008-08-20 12:16 ` Brian Dessent
2008-08-20 12:40 ` Brian Dessent
2008-08-20 13:15   ` Robert Schmidt [this message]
2008-08-20 13:31     ` Brian Dessent
2008-08-20 16:12     ` Christopher Faylor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='g8h5bl$vsd$1@ger.gmane.org' \
    --to=rschm@broadpark.no \
    --cc=cygwin-talk@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).