Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Nov 2002 18:22:22 +0900 (JST)
From:      Hideo Kogoe <Hideo.Kogoe@Sun.COM>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        Hideo Kogoe <Hideo.Kogoe@Sun.COM>
Subject:   bin/45584: read builtin function of sh does not read standard input
Message-ID:  <200211220922.gAM9MMcw095649@vaio.Japan.Sun.COM>

next in thread | raw e-mail | index | archive | help

>Number:         45584
>Category:       bin
>Synopsis:       read builtin function of sh does not read standard input
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Nov 22 01:30:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Hideo Kogoe
>Release:        FreeBSD 4.7-RELEASE i386
>Organization:
Sun Microsystems K.K.
>Environment:
System: FreeBSD vaio.Japan.Sun.COM 4.7-RELEASE FreeBSD 4.7-RELEASE #0: Mon Nov 18 14:46:18 JST 2002 root@vaio.Japan.Sun.COM:/usr/src/sys/compile/VAIO i386

	SONY VAIO PCG-R505R/GK running a customer kernel

>Description:
	The read builtin function of /bin/sh does not read the
	standard input correctly.  Refer to the How-To-Repeat
	section.

>How-To-Repeat:
	$ echo Hello | read line; echo $line

	$ echo Hello | while read line; do echo $line; done
	Hello
	$

    Just for reference, on Solaris, for example,

	$ echo Hello | read line; echo $line
	Hello
	$ echo Hello | while read line; do echo $line; done
	Hello
	$ 

    Accroding to the specification of POSIX shell, the read
    function doesn't behave correctly.

>Fix:
	Putting them into a sub-shell seems to work fine. 

	$ echo Hello | (read line; echo $line)
	Hello
	$ 
>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200211220922.gAM9MMcw095649>