From owner-freebsd-bugs@FreeBSD.ORG Thu Dec 11 04:40:01 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B68811065678 for ; Thu, 11 Dec 2008 04:40:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 8BF808FC2D for ; Thu, 11 Dec 2008 04:40:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id mBB4e1fL053579 for ; Thu, 11 Dec 2008 04:40:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id mBB4e1kd053578; Thu, 11 Dec 2008 04:40:01 GMT (envelope-from gnats) Resent-Date: Thu, 11 Dec 2008 04:40:01 GMT Resent-Message-Id: <200812110440.mBB4e1kd053578@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Michael Proto Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 94A7A1065672 for ; 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 ; 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 ) by mail3.sea5.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 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 ; 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 To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/129566: behavioral change of "read" builtin for sh on 8-CURRENT X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Michael Proto List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Dec 2008 04:40:01 -0000 >Number: 129566 >Category: bin >Synopsis: behavioral change of "read" builtin for sh on 8-CURRENT >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Dec 11 04:40:01 UTC 2008 >Closed-Date: >Last-Modified: >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: >Unformatted: