delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1999/08/04/10:52:37

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin/>
List-Help: <mailto:cygwin-help AT sourceware DOT cygnus DOT com>,
<http://sourceware.cygnus.com/ml/#faqs>
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
Message-ID: <B3953869CBF8D211A1E50004AC4C1B5402F42A@ULTIMATE2>
From: "Lincoln, W. Terry" <terryl AT ultimatetechnology DOT com>
To: "'tien ho'" <h_tien AT hotmail DOT com>, cygwin AT sourceware DOT cygnus DOT com
Subject: RE: ctl-d, bash and java
Date: Wed, 4 Aug 1999 09:39:41 -0400
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2448.0)

------_=_NextPart_001_01BEDE87.3A17A272
Content-Type: text/plain;
	charset="iso-8859-1"

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 AT engineer DOT 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 AT hotmail DOT com]
> Sent: Tuesday, August 03, 1999 9:11 AM
> To: cygwin AT sourceware DOT cygnus DOT 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 AT sourceware DOT cygnus DOT com
> 

------_=_NextPart_001_01BEDE87.3A17A272
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2448.0">
<TITLE>RE: ctl-d, bash and java</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2>My uname -a says:</FONT>
</P>

<P><FONT SIZE=3D2>CYGWIN_NT-4.0 MYPC 21.0 (0.8/1/1) 1998-12-30 20:29:58 =
i686 unknown</FONT>
</P>

<P><FONT SIZE=3D2>When I type:</FONT>
</P>

<P><FONT SIZE=3D2>$ cat</FONT>
<BR><FONT SIZE=3D2>abcd&lt;ctrl-d&gt;</FONT>
</P>

<P><FONT SIZE=3D2>Bash prompts:</FONT>
<BR><FONT SIZE=3D2>abcd$ </FONT>
</P>

<P><FONT SIZE=3D2>But as soon as I type a character (x) this =
happens:</FONT>
</P>

<P><FONT SIZE=3D2>abcd$ abcdx</FONT>
</P>

<P><FONT SIZE=3D2>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!</FONT></P>
<BR>

<P><FONT SIZE=3D2>W. Terry Lincoln - Senior =
Engineer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \&nbsp;&nbsp;&nbsp;&nbsp; =
\&nbsp;&nbsp; _&nbsp;&nbsp; /</FONT>
<BR><FONT SIZE=3D2>Ultimate Technology =
Corporation&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
\&nbsp;&nbsp;&nbsp;&nbsp; \ |J| /</FONT>
<BR><FONT SIZE=3D2>a Tridex Company =
(NASDAQ:trdx)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp; \&nbsp;&nbsp;&nbsp;&nbsp; _|E|_</FONT>
<BR><FONT SIZE=3D2>ICQ# =
39362285&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \&nbsp;&nbsp; |_ S =
_|</FONT>
<BR><FONT SIZE=3D2>Email: =
WTerryLincoln AT engineer DOT com&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp; \&nbsp;&nbsp;&nbsp; |U|</FONT>
<BR><FONT SIZE=3D2>WWW1:&nbsp; =
www.AngelFire.com/ny/TerryLincoln&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \ / |S| =
\</FONT>
<BR><FONT SIZE=3D2>WWW2:&nbsp; &lt;<A =
HREF=3D"http://terrylincoln.isonfire.com" =
TARGET=3D"_blank">http://terrylincoln.isonfire.com</A>&gt;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp; \&nbsp; | |</FONT>
<BR><FONT =
SIZE=3D2>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D ~~~~~</FONT>
<BR><FONT SIZE=3D2>Opinions expressed do not represent the management =
of UTC.</FONT>
<BR><FONT SIZE=3D2>&gt; -----Original Message-----</FONT>
<BR><FONT SIZE=3D2>&gt; From: tien ho [<A =
HREF=3D"mailto:h_tien AT hotmail DOT com">mailto:h_tien AT hotmail DOT com</A>]</FONT>=

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

</BODY>
</HTML>
------_=_NextPart_001_01BEDE87.3A17A272--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019