This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

interactive bash multiple NLs (revisited)


Hello all,

There was a thread earlier in April mentioning the multiple NLs in an
interactive shell program.  The symptoms for the short script, t.sh:
	arg1=dummy1
	arg2=dummy2
	echo -n "Enter [$arg1]: "
	read arg1
	echo -n "Enter [$arg2]: "
	read arg2
	echo "arg1=$arg1"
	echo "arg2=$arg2"
was that arg1 would correctly prompted, but a arg2 would just fly by
and get a newline.  This appears to happen with b18 under Win95 (not WinNT),
and under b19.1 under Win95 and WinNT.

The crazy thing was that if the script was feed info from a redirected file,
the read arguments were just fine.

The problem appears to be that cdk/src/winsup/console.cc converts CRs to
NLs because the ICRNL flag is set.  If one comments out the conversion code
the symptoms go away (see patch below).

Notably, this is not the best way to fix the problem.  One should be able to
turn off the ICRNL translation just by using "stty -icrnl", but this doesn't
appear to work.

Another tack would be to find where the iflags are being set and adjust them
appropriately.  Any one got ideas where?  I haven't found where yet.

-Paul

### BEGIN PATCH b18 cdk/src/winsup/console.cc ####
*** /tmp/,RCSt158       Fri May  1 08:36:52 1998
--- console.cc  Thu Apr 30 13:56:06 1998
***************
*** 1277,1283 ****
          len = dst - buf;
            syscall_printf ("rf fail len set to  %d\n", len);
        }
! 
        if (iflag_ & ICRNL)
        {
          /* Turn CR into NL */
--- 1277,1283 ----
          len = dst - buf;
            syscall_printf ("rf fail len set to  %d\n", len);
        }
! #if 0
        if (iflag_ & ICRNL)
        {
          /* Turn CR into NL */
***************
*** 1287,1293 ****
                buf[i] = '\n';
            }
        }
! 
        syscall_printf ("rf fail 3\n");
        if (iflag_ & INLCR)
        {
--- 1287,1293 ----
                buf[i] = '\n';
            }
        }
! #endif
        syscall_printf ("rf fail 3\n");
        if (iflag_ & INLCR)
        {
### END PATCH b18 cdk/src/winsup/console.cc ####
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]