Subject: Re: bash-shell output
From: [email-masked] (Charles Curley)

8 Feb 1998 09:34:53 -0800
Message-ID: <[email-masked]>
References: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
To: "Elliott A. Lowe" <[email-masked]>
Cc: <[email-masked]>, "Nils Goesche" <[email-masked]>

I'm taking this off the NT Emacs list because it is off-topic there.

Elliot, your solution "works" but may cause problems down the road. Yes,
stderr is unbuffered. However, when the user pipes or re-directs the
output, output to stderr is not piped or re-directed. So the output does
not go to the pipe or output file. One solution the user could use is to
pipe or re-direct both stdout and stderr, but then all error messages go to
the pipe or output file. This is not what you want either. Sorry, but the
best solution is to ise printf and fflush.

At 19:15 4/2/98 -0800, Elliott A. Lowe wrote:
>Bash is actually behaving correctly; your printf() call would do the same
>thing on Unix.  Since stdout is by default fully line-buffered, any text
>that isn't terminated with a newline must be flushed before it will show up.
>
>The way I get around this is to write the prompt to stderr using fprintf(),
>since stderr is by default unbuffered.
>
>Elliott
>
>-----Original Message-----
>From: Nils Goesche <[email-masked]>
>To: [email-masked] <[email-masked]>
>Cc: [email-masked] <[email-masked]>
>Date: Wednesday, February 04, 1998 4:11 PM
>Subject: bash-shell output
>
>
>>Hi!
>>
>>The following program doesn't work properly when run from bash
>>(with `M-x shell' from within Emacs):
>>
>>#include <stdio.h>
>>
>>int main()
>>{
>> int i;
>>
>> printf("Enter number: ");
>> /* fflush(NULL); */
>> scanf("%d", &i);
>> printf("Got %d.\n", i);
>> return 0;
>>}
>>
>>You have to uncomment that fflush-line. But the usual shells
>>like command.com or 4nt don't need that line. This is somewhat
>>annoying. Can I at least force the shell somehow to flush
>>input/output buffers? Some other programs are just unusable
>>because of this behavior.
>>
>>--
>>Nils Goesche
>>My obscure opinions are my very own.
>>
>
>

		-- C^2

Looking for fine software and/or web pages?
http://web.idirect.com/~ccurley
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".