From: jeffers AT redrose DOT net (David Jeffers) Subject: Broken stdin? 25 Oct 1996 18:07:56 -0700 Sender: daemon AT cygnus DOT com Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: <199610252345.QAA09748.cygnus.gnu-win32@cygnus.com> Original-To: gnu-win32 AT cygnus DOT com Original-Sender: owner-gnu-win32 AT cygnus DOT com Is stdin broken in bash? The following c program was tested using the bash shell... test.c #include char line[100]; int value; main() { (void) printf("Enter a value: "); (void) fgets(line, sizeof(line), stdin); (void) sscanf(line, "%d", &value); (void) printf("Twice %d is %d\n", value, value * 2); return (0); } This should allow the user to enter a value, but instead the program produces the following: $ test $ Enter a value: $ Twice 0 is 0 The program 'returns' even though no "\n" is added. Out of curiosity I also tested a shell script version of the same program: test.sh echo -n 'Enter a value:' >&2 read ans echo "$ans" This produces: $ Enter a value: $ The shell script also returns without waiting for a response. The test.c program, however, does work correctly using the dos shell. I'd be grateful to learn how these programs perform on other users machines using bash. -- David Jeffers - For help on using this list, send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".