From root@jellydonut.org  Thu Dec 11 04:33:57 2008
Return-Path: <root@jellydonut.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 94A7A1065672
	for <freebsd-gnats-submit@freebsd.org>; Thu, 11 Dec 2008 04:33:57 +0000 (UTC)
	(envelope-from root@jellydonut.org)
Received: from mail3.sea5.speakeasy.net (mail3.sea5.speakeasy.net [69.17.117.5])
	by mx1.freebsd.org (Postfix) with ESMTP id 6DD3B8FC08
	for <freebsd-gnats-submit@freebsd.org>; Thu, 11 Dec 2008 04:33:57 +0000 (UTC)
	(envelope-from root@jellydonut.org)
Received: (qmail 26084 invoked from network); 11 Dec 2008 04:07:16 -0000
Received: from marconi.jellydonut.org (HELO localhost) ([216.27.165.148])
          (envelope-sender <root@jellydonut.org>)
          by mail3.sea5.speakeasy.net (qmail-ldap-1.03) with SMTP
          for <freebsd-gnats-submit@freebsd.org>; 11 Dec 2008 04:07:15 -0000
Received: from minibsd8-dev.localnet (192.168.0.24) by marconi.localnet
Received: from minibsd8-dev.localnet (localhost [127.0.0.1])
	by minibsd8-dev.localnet (8.14.3/8.14.3) with ESMTP id mBB47Eo1001180
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 10 Dec 2008 23:07:14 -0500 (EST)
	(envelope-from root@minibsd8-dev.localnet)
Received: (from root@localhost)
	by minibsd8-dev.localnet (8.14.3/8.14.3/Submit) id mBB47EWJ001179;
	Wed, 10 Dec 2008 23:07:14 -0500 (EST)
	(envelope-from root)
Message-Id: <200812110407.mBB47EWJ001179@minibsd8-dev.localnet>
Date: Wed, 10 Dec 2008 23:07:14 -0500 (EST)
From: Michael Proto <mike@jellydonut.org>
Reply-To: Michael Proto <mike@jellydonunt.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: behavioral change of "read" builtin for sh on 8-CURRENT
X-Send-Pr-Version: 3.113
X-GNATS-Notify: gcooper@FreeBSD.org

>Number:         129566
>Category:       bin
>Synopsis:       behavioral change of "read" builtin for sh(1) on 8-CURRENT [regression]
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Dec 11 04:40:01 UTC 2008
>Closed-Date:    Sun Mar 22 08:15:07 UTC 2009
>Last-Modified:  Sun May 31 19:50:01 UTC 2009
>Originator:     Charlie &
>Release:        FreeBSD 8.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD minibsd8-dev.localnet 8.0-CURRENT FreeBSD 8.0-CURRENT #0: Thu Dec 4 15:58:57 EST 2008 root@minibsd8-dev.localnet:/usr/obj/usr/src/sys/MINIBSD8-DEV i386



>Description:
	I've noticed a behavioral difference of the "read" builtin statement within /bin/sh on CURRENT and I'm hoping someone can point me in the right direction on how to restore the old behavior.

I have a /bin/sh script that accepts input for IP address information:

#!/bin/sh
set -x
DEFINT=vr0
DEFIP=192.168.0.1
DEFMASK=255.255.255.0
read -p "Enter network interface [$DEFINT]: " -t 5 INT
read -p "Enter IP address [$DEFIP]: " -t 5 IP
read -p "Enter netmask [$DEFMASK]: " -t 5 MASK
echo ${INT:=$DEFINT} : ${IP:=$DEFIP}/${MASK:=$DEFMASK}


This script waits for terminal input for each of the above variables (INT, IP, MASK) and defaults to a script-provided value if no input is entered in 5 seconds for each variable. On 6.x and 7.x if I simply hit Enter at the prompt (and don't provide any input) no value is assigned to the variable so my INT, IP, and MASK variables are set to null and the parameter substitution of the DEF* variables works as expected.

On 8-CURRENT if I hit Enter with no input at the prompt the system seems to recognize the newline as input and continues to sit there until I hit Enter again. When I do this there appears to be a strange unprintable value assigned to the INT, IP, and MASK variables yet the variable subsitution doesn't work correctly.

The man page on sh lists the following behavior for read:

     read [-p prompt] [-t timeout] [-er] variable ...
             The prompt is printed if the -p option is specified and the stan-
             dard input is a terminal.  Then a line is read from the standard
             input.  The trailing newline is deleted from the line and the
             line is split as described in the section on White Space
             Splitting (Field Splitting) above, and the pieces are assigned to
             the variables in order.  If there are more pieces than variables,
             the remaining pieces (along with the characters in IFS that sepa-
             rated them) are assigned to the last variable.  If there are more
             variables than pieces, the remaining variables are assigned the
             null string.


As I interpret this, read should delete the trailing newline and assign a null value since there is is no "input" before the newline. Then the variable substitution should take over and assign the DEF* variables appropriately. 6 and 7 follow this but 8 does not.

Here's the output of the script (with set -x) to help show what I'm seeing.

This is on 6 and 7:

+ DEFINT=vr0
+ DEFIP=192.168.0.1
+ DEFMASK=255.255.255.0
+ read -p Enter network interface [vr0]:  -t 5 INT
Enter network interface [vr0]:
+ read -p Enter IP address [192.168.0.1]:  -t 5 IP
Enter IP address [192.168.0.1]:
+ read -p Enter netmask [255.255.255.0]:  -t 5 MASK
Enter netmask [255.255.255.0]:
+ echo vr0 : 192.168.0.1/255.255.255.0
vr0 : 192.168.0.1/255.255.255.0


And this is what I see with 8:

+ DEFINT=vr0
+ DEFIP=192.168.0.1
+ DEFMASK=255.255.255.0
+ read -p Enter network interface [vr0]:  -t 5 INT
Enter network interface [vr0]:
+ read -p Enter IP address [192.168.0.1]:  -t 5 IP
Enter IP address [192.168.0.1]:
+ read -p Enter netmask [255.255.255.0]:  -t 5 MASK
Enter netmask [255.255.255.0]:
/: cho
/:

Strange that the "echo" statement is missing the first "e" character in the debug output.

Even stranger on 8-CURRENT, if I *do* enter input before the newline (say I change the IP address or the network interface), the first character is not echoed back to the screen but is still saved to the variable. Here's an example when I run the script and provide input at each prompt:

+ DEFINT=vr0
+ DEFIP=192.168.0.1
+ DEFMASK=255.255.255.0
+ read -p Enter network interface [vr0]:  -t 5 INT
Enter network interface [vr0]: r0
+ read -p Enter IP address [192.168.0.1]:  -t 5 IP
Enter IP address [192.168.0.1]: 92.168.0.1
+ read -p Enter netmask [255.255.255.0]:  -t 5 MASK
Enter netmask [255.255.255.0]: 55.255.255.0
+ echo br0 : 192.168.0.1/255.255.255.0
br0 : 192.168.0.1/255.255.255.0
+ echo ifconfig br0 inet 192.168.0.1 netmask 255.255.255.0

Notice that when I'm prompted, the first character doesn't echo but is still saved in the variable.


Does anyone else see this same behavior? Any ideas on how to reset it back to how it works in STABLE? I'm not doing anything special with IFS so I'm stumped on how to troubleshoot this.
>How-To-Repeat:
	use the above script in 8-CURRENT and validate output when Enter/Return is hit on the keyboard when waiting for default values
>Fix:

	unknown


>Release-Note:
>Audit-Trail:

From: "Garrett Cooper" <yanefbsd@gmail.com>
To: "Michael Proto" <mike@jellydonunt.org>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/129566: behavioral change of "read" builtin for sh on 8-CURRENT
Date: Wed, 10 Dec 2008 22:57:48 -0800

 That is indeed a problem. Usually one EOL char would terminate read
 but now it's two.
 
 I'm reproducing this issue on an older version of CURRENT (~2.5 weeks
 old). I'll try looking through the commit logs for anything fishy...
 
 -Garrett

From: "Garrett Cooper" <yanefbsd@gmail.com>
To: "Michael Proto" <mike@jellydonunt.org>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/129566: behavioral change of "read" builtin for sh on 8-CURRENT
Date: Thu, 11 Dec 2008 00:52:33 -0800

     None of the changes in .../src/bin/sh are causing this (I rolled
 back all files individually changed in the past 2 years and I couldn't
 find any problem files). It's most likely related to the MPSAFETTY
 changes.
     It'd be nice to use a livefs CD from before the MPSAFETTY changes
 were merged in to verify this.
 -Garrett

From: "Garrett Cooper" <yanefbsd@gmail.com>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: bin/129566: behavioral change of "read" builtin for sh on 8-CURRENT
Date: Sun, 14 Dec 2008 02:34:13 -0800

 Cannot reach originator via email. Please change originator contact to
 my email address (gcooper@) until another one can be established as I
 can easily reproduce this issue.
 -Garrett

From: Jilles Tjoelker <jilles@stack.nl>
To: bug-followup@FreeBSD.org
Cc: ed@freebsd.org, yanefbsd@gmail.com
Subject: Re: bin/129566: behavioral change of "read" builtin for sh(1) on
	8-CURRENT
Date: Fri, 6 Mar 2009 18:37:10 +0100

 I do not have an 8-CURRENT box to test on, but it seems the problem with
 read -t is indeed due to the new tty layer.
 
 What the read builtin with -t does, is as follows: set "raw" terminal
 mode, select for input, put back terminal modes (all sets with TCSANOW).
 
 The issue is the behaviour when the terminal is switched from
 non-canonical to canonical mode while there is data queued. POSIX seems
 vague about this. You can see the behaviour without relying on
 non-standard options to the read builtin like this:
 
 inf=`stty -g`; stty raw; sleep 2; echo -n :; stty "$inf"; read x; echo "$x"
 
 Something should be typed during the sleep 2.
 
 I can distinguish three behaviours: FreeBSD 7 reprocesses the characters
 in the input queue (possibly echoing them, sending signals, terminating
 the line, etc, as appropriate), Linux puts the characters in the input
 line but does not do any processing (for example, a backspace shows up
 as ^H or ^? after a ^R) and Solaris keeps the characters in the input
 queue but not in the input line (^R does not show them; however, a
 newline is still required for the read to complete).
 
 The new tty layer code seems to behave like Solaris here (only from
 reading the code, not experimentation).
 
 Also note that <Return> is ^M, which is normally mapped to newline (^J)
 but not under 'stty raw'. So that will not terminate a line if the input
 queue is not reprocessed.
 
 The code in sh(1) will only work properly with the FreeBSD 7 behaviour.
 A workaround is possible by reading input while in raw mode and putting
 it back using TIOCSTI after having enabled ICANON, but this is
 necessarily racy and does not fix running 7.x sh(1) on 8.x.
 
 By the way, shells/44bsd-csh also does trickery with canonical mode
 (Esc/^D filename completion).
 
 -- 
 Jilles Tjoelker

From: Ed Schouten <ed@80386.nl>
To: bug-followup@FreeBSD.org, mike@jellydonunt.org
Cc: jilles@stack.nl
Subject: Re: bin/129566: behavioral change of "read" builtin for sh(1) on
	8-CURRENT [regression]
Date: Sun, 8 Mar 2009 20:03:37 +0100

 --8Ioc0IVuiHZoupes
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 Hi,
 
 As Jilles pointed out, the new TTY layer does not perform any
 post-processing before returning data to userspace. This makes the
 design of the TTY layer a lot more simple, while still complying to the
 standards.
 
 This means sh(1)'s behaviour it not correct, because it calls select()
 with ICRNL disabled. The following patch should fix this:
 
 Index: miscbltin.c
 =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=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 --- miscbltin.c	(revision 189489)
 +++ miscbltin.c	(working copy)
 @@ -147,6 +147,7 @@
  		if (tcgetattr(0, &told) =3D=3D 0) {
  			memcpy(&tnew, &told, sizeof(told));
  			cfmakeraw(&tnew);
 +			tnew.c_iflag |=3D ICRNL;
  			tcsetattr(0, TCSANOW, &tnew);
  			tsaved =3D 1;
  		}
 
 Please let me know if it fixes your issue. If it does, I'll commit it to
 SVN and MFC it as well.
 
 --=20
  Ed Schouten <ed@80386.nl>
  WWW: http://80386.nl/
 
 --8Ioc0IVuiHZoupes
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.9 (FreeBSD)
 
 iEYEARECAAYFAkm0FokACgkQ52SDGA2eCwVVYwCcDDwXL2gw3GDE4Ak1iw9Jdabr
 ptoAnjIpxhLsoU4egBZvcVF2e8YB/TRa
 =xY6E
 -----END PGP SIGNATURE-----
 
 --8Ioc0IVuiHZoupes--

From: Ed Schouten <ed@80386.nl>
To: bug-followup@FreeBSD.org
Cc: Jilles Tjoelker <jilles@stack.nl>
Subject: Re: bin/129566: behavioral change of "read" builtin for sh(1) on
	8-CURRENT [regression]
Date: Sun, 8 Mar 2009 20:04:33 +0100

 --6GaTvyp6jYG0kAmd
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 Hi,
 
 It seems the reporter's address is not valid, because the domain does
 not exist. I'll just commit it to SVN, then.
 
 --=20
  Ed Schouten <ed@80386.nl>
  WWW: http://80386.nl/
 
 --6GaTvyp6jYG0kAmd
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.9 (FreeBSD)
 
 iEYEARECAAYFAkm0FsEACgkQ52SDGA2eCwUmbACeJOoFCzpYLbUelg85bGrs2BZ6
 EqsAn3bkTU8q8+Le/lNpq68R96Fv0ku5
 =Z8CJ
 -----END PGP SIGNATURE-----
 
 --6GaTvyp6jYG0kAmd--
State-Changed-From-To: open->patched 
State-Changed-By: ed 
State-Changed-When: Sun Mar 8 19:10:57 UTC 2009 
State-Changed-Why:  
Fix committed to SVN. Will be MFC'd after two weeks. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=129566 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/129566: commit references a PR
Date: Sun,  8 Mar 2009 19:10:07 +0000 (UTC)

 Author: ed
 Date: Sun Mar  8 19:09:55 2009
 New Revision: 189542
 URL: http://svn.freebsd.org/changeset/base/189542
 
 Log:
   Don't disable CR-to-NL translation when waiting for data to arrive.
   
   A difference between the old and the new TTY layer is that the new
   implementation does not perform any post-processing before returning
   data back to userspace when calling read().
   
   sh(1)'s read turns the TTY into a raw mode before calling select(). This
   means that the first character will not receive any ICRNL processing.
   Inherit this flag from the original terminal attributes.
   
   Even though this issue is not present on RELENG_*, I'm MFCing it to make
   sh(1) in jails behave better.
   
   PR:		bin/129566
   MFC after:	2 weeks
 
 Modified:
   head/bin/sh/miscbltin.c
 
 Modified: head/bin/sh/miscbltin.c
 ==============================================================================
 --- head/bin/sh/miscbltin.c	Sun Mar  8 19:07:44 2009	(r189541)
 +++ head/bin/sh/miscbltin.c	Sun Mar  8 19:09:55 2009	(r189542)
 @@ -147,6 +147,7 @@ readcmd(int argc __unused, char **argv _
  		if (tcgetattr(0, &told) == 0) {
  			memcpy(&tnew, &told, sizeof(told));
  			cfmakeraw(&tnew);
 +			tnew.c_iflag |= told.c_iflag & ICRNL;
  			tcsetattr(0, TCSANOW, &tnew);
  			tsaved = 1;
  		}
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/129566: commit references a PR
Date: Sun, 22 Mar 2009 08:09:38 +0000 (UTC)

 Author: ed
 Date: Sun Mar 22 08:09:16 2009
 New Revision: 190253
 URL: http://svn.freebsd.org/changeset/base/190253
 
 Log:
   MFC:
   
     Don't disable CR-to-NL translation when waiting for data to arrive.
   
     A difference between the old and the new TTY layer is that the new
     implementation does not perform any post-processing before returning
     data back to userspace when calling read().
   
     sh(1)'s read turns the TTY into a raw mode before calling select(). This
     means that the first character will not receive any ICRNL processing.
     Inherit this flag from the original terminal attributes.
   
     Even though this issue is not present on RELENG_*, I'm MFCing it to make
     sh(1) in jails behave better.
   
     PR:		bin/129566
 
 Modified:
   stable/7/bin/sh/   (props changed)
   stable/7/bin/sh/miscbltin.c
 
 Modified: stable/7/bin/sh/miscbltin.c
 ==============================================================================
 --- stable/7/bin/sh/miscbltin.c	Sun Mar 22 06:47:29 2009	(r190252)
 +++ stable/7/bin/sh/miscbltin.c	Sun Mar 22 08:09:16 2009	(r190253)
 @@ -147,6 +147,7 @@ readcmd(int argc __unused, char **argv _
  		if (tcgetattr(0, &told) == 0) {
  			memcpy(&tnew, &told, sizeof(told));
  			cfmakeraw(&tnew);
 +			tnew.c_iflag |= told.c_iflag & ICRNL;
  			tcsetattr(0, TCSANOW, &tnew);
  			tsaved = 1;
  		}
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: ed 
State-Changed-When: Sun Mar 22 08:15:06 UTC 2009 
State-Changed-Why:  
Change MFCd to RELENG_6 and RELENG_7. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=129566 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/129566: commit references a PR
Date: Sun, 22 Mar 2009 08:14:12 +0000 (UTC)

 Author: ed
 Date: Sun Mar 22 08:14:01 2009
 New Revision: 190254
 URL: http://svn.freebsd.org/changeset/base/190254
 
 Log:
   MFC r189542:
   
     Don't disable CR-to-NL translation when waiting for data to arrive.
   
     A difference between the old and the new TTY layer is that the new
     implementation does not perform any post-processing before returning
     data back to userspace when calling read().
   
     sh(1)'s read turns the TTY into a raw mode before calling select(). This
     means that the first character will not receive any ICRNL processing.
     Inherit this flag from the original terminal attributes.
   
     Even though this issue is not present on RELENG_*, I'm MFCing it to make
     sh(1) in jails behave better.
   
     PR:           bin/129566
 
 Modified:
   stable/6/bin/sh/   (props changed)
   stable/6/bin/sh/miscbltin.c
 
 Modified: stable/6/bin/sh/miscbltin.c
 ==============================================================================
 --- stable/6/bin/sh/miscbltin.c	Sun Mar 22 08:09:16 2009	(r190253)
 +++ stable/6/bin/sh/miscbltin.c	Sun Mar 22 08:14:01 2009	(r190254)
 @@ -147,6 +147,7 @@ readcmd(int argc __unused, char **argv _
  		if (tcgetattr(0, &told) == 0) {
  			memcpy(&tnew, &told, sizeof(told));
  			cfmakeraw(&tnew);
 +			tnew.c_iflag |= told.c_iflag & ICRNL;
  			tcsetattr(0, TCSANOW, &tnew);
  			tsaved = 1;
  		}
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/129566: commit references a PR
Date: Sun, 31 May 2009 19:37:26 +0000 (UTC)

 Author: jilles
 Date: Sun May 31 19:37:06 2009
 New Revision: 193185
 URL: http://svn.freebsd.org/changeset/base/193185
 
 Log:
   sh: Make read's timeout (-t) apply to the entire line, not only the first
   character.
   
   This avoids using non-standard behaviour of the old (upto FreeBSD 7) TTY
   layer: it reprocesses the input queue when switching to canonical mode. The
   new TTY layer does not provide this functionality and so read -t worked
   very poorly (first character is not echoed, cannot be backspaced but is
   still read).
   
   This also agrees with what most other shells with read -t do.
   
   PR:		bin/129566
   Reviewed by:	stefanf
   Approved by:	ed (mentor)
 
 Modified:
   head/bin/sh/miscbltin.c
   head/bin/sh/sh.1
 
 Modified: head/bin/sh/miscbltin.c
 ==============================================================================
 --- head/bin/sh/miscbltin.c	Sun May 31 19:35:41 2009	(r193184)
 +++ head/bin/sh/miscbltin.c	Sun May 31 19:37:06 2009	(r193185)
 @@ -103,8 +103,6 @@ readcmd(int argc __unused, char **argv _
  	struct timeval tv;
  	char *tvptr;
  	fd_set ifds;
 -	struct termios told, tnew;
 -	int tsaved;
  
  	rflag = 0;
  	prompt = NULL;
 @@ -151,26 +149,11 @@ readcmd(int argc __unused, char **argv _
  
  	if (tv.tv_sec >= 0) {
  		/*
 -		 * See if we can disable input processing; this will
 -		 * not give the desired result if we are in a pipeline
 -		 * and someone upstream is still in line-by-line mode.
 -		 */
 -		tsaved = 0;
 -		if (tcgetattr(0, &told) == 0) {
 -			memcpy(&tnew, &told, sizeof(told));
 -			cfmakeraw(&tnew);
 -			tnew.c_iflag |= told.c_iflag & ICRNL;
 -			tcsetattr(0, TCSANOW, &tnew);
 -			tsaved = 1;
 -		}
 -		/*
  		 * Wait for something to become available.
  		 */
  		FD_ZERO(&ifds);
  		FD_SET(0, &ifds);
  		status = select(1, &ifds, NULL, NULL, &tv);
 -		if (tsaved)
 -			tcsetattr(0, TCSANOW, &told);
  		/*
  		 * If there's nothing ready, return an error.
  		 */
 
 Modified: head/bin/sh/sh.1
 ==============================================================================
 --- head/bin/sh/sh.1	Sun May 31 19:35:41 2009	(r193184)
 +++ head/bin/sh/sh.1	Sun May 31 19:37:06 2009	(r193185)
 @@ -32,7 +32,7 @@
  .\"	from: @(#)sh.1	8.6 (Berkeley) 5/4/95
  .\" $FreeBSD$
  .\"
 -.Dd October 7, 2006
 +.Dd May 31, 2009
  .Dt SH 1
  .Os
  .Sh NAME
 @@ -1949,7 +1949,7 @@ If the
  .Fl t
  option is specified and the
  .Ar timeout
 -elapses before any input is supplied,
 +elapses before a complete line of input is supplied,
  the
  .Ic read
  command will return an exit status of 1 without assigning any values.
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: Jilles Tjoelker <jilles@stack.nl>
To: bug-followup@FreeBSD.org, mike@jellydonunt.org
Cc:  
Subject: Re: bin/129566: behavioral change of "read" builtin for sh(1) on
	8-CURRENT [regression]
Date: Sun, 31 May 2009 21:47:57 +0200

 I have committed another change. The timeout in the read builtin now
 applies to the entire read, not the first character, and the weirdness
 is gone.
 
 I suggest changing the script as follows:
 
 #!/bin/sh
 set -x
 DEFINT=vr0
 DEFIP=192.168.0.1
 DEFMASK=255.255.255.0
 if read -t 5 -p "Press Enter now if you want to configure the network: " dummy; then
 	read -p "Enter network interface [$DEFINT]: " INT
 	read -p "Enter IP address [$DEFIP]: " IP
 	read -p "Enter netmask [$DEFMASK]: " MASK
 else
 	echo 'Using defaults'
 fi
 echo ${INT:=$DEFINT} : ${IP:=$DEFIP}/${MASK:=$DEFMASK}
 
 This should work well on both 8.x and older versions.
 
 -- 
 Jilles Tjoelker
>Unformatted:
