ctl-d, bash and java
Lincoln, W. Terry
terryl@ultimatetechnology.com
Tue Aug 31 23:49:00 GMT 1999
Title: RE: ctl-d, bash and java
My uname -a says:
CYGWIN_NT-4.0 MYPC 21.0 (0.8/1/1) 1998-12-30 20:29:58 i686 unknown
When I type:
$ cat
abcd<ctrl-d>
Bash prompts:
abcd$
But as soon as I type a character (x) this happens:
abcd$ abcdx
IOW, bash (or readline) is using c-d as a way of copying the line to the keyboard buffer; or *not clearing it out*. Then when the next key is pressed the earlier text reappears!
W. Terry Lincoln - Senior EngineerÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ \ÃÂ ÃÂ ÃÂ ÃÂ \ÃÂ ÃÂ _ÃÂ ÃÂ /
Ultimate Technology CorporationÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ \ÃÂ ÃÂ ÃÂ ÃÂ \ |J| /
a Tridex Company (NASDAQ:trdx)ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ \ÃÂ ÃÂ ÃÂ ÃÂ _|E|_
ICQ# 39362285ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ \ÃÂ ÃÂ |_ S _|
Email: WTerryLincoln@engineer.comÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ \ÃÂ ÃÂ ÃÂ |U|
WWW1:ÃÂ www.AngelFire.com/ny/TerryLincolnÃÂ ÃÂ ÃÂ ÃÂ ÃÂ \ / |S| \
WWW2:ÃÂ < http://terrylincoln.isonfire.com >ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ \ÃÂ | |
================================================ ~~~~~
Opinions expressed do not represent the management of UTC.
> -----Original Message-----
> From: tien ho [ mailto:h_tien@hotmail.com ]
> Sent: Tuesday, August 03, 1999 9:11 AM
> To: cygwin@sourceware.cygnus.com
> Subject: ctl-d, bash and java
>
>
> 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
>
More information about the Cygwin
mailing list