This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
ctl-d, bash and java
- To: cygwin@sourceware.cygnus.com
- Subject: ctl-d, bash and java
- From: "tien ho" <h_tien@hotmail.com>
- Date: Tue, 03 Aug 1999 06:10:59 PDT
Hi everybody,
I'm a newbie in bash. I'm testing some examples of javacc. I'm using cygwin
b20.1 (bash and make) on NT4.0, SP4, english version and jdk 1.2 to test
javacc simple examples. I do need EOF (ctl-d) to shows the results.
Ctl-d is using to stop the cat in the command cat>myfile. It works fine in
cygwin.
The behaviour of bash on ctl-d is quite special (nothing set in IGNOREEOF).
If I'm right, it was defined the following:
If ctl-d is the first character, then it returns EOF, else delete the
character under the cursor.
To test it:
I type the command abcd<ctl-d>, I will received the following message:
bash: abcd: command not found
If ctl-d is the first character, bash disappears.
To test with java, I wrote a very simple test program, which calls the
function System.in.read(b[]). Following is the code:
public class sysIn {
public static void main (String args[]) {
int i;
byte b[]= new byte[256];
try
{
i = System.in.read(b);
}
catch (IOException ioEx)
{
System.err.println(ioEx);
return;
}
System.out.println(i);
for (int j=0; j < i; j++)
System.out.print(b[j]+" ");
System.out.println();
}
}
It displays 1 13 (code of ctl-d), when ctl-d is keyed.
Bash disappers, when "abcd<ctl-d>" were keyed. How can I explain it?
How it reacts with fgets()?
#include <stdio.h>
int main(int argc, char** argv)
{
char s[256];
if (fgets(s,256, stdin ))
{
printf("\nlen: %i\n", strlen(s));
printf("text: %s\n", s);
}
else
printf("\nempty\n");
return (1);
}
When I start the test and gave abcd<ctl-d>, I recieved:
len: 4
text: abcd
bash-2.02$
I gave <ENTER>, bash treats the command abcd and returns
bash: abcd: command not found
How can I changed the behaviour of bash, so that I can received ctl-d key
stroke and input buffer will be flushed?
Thank you for helps
Tien
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com