[comp.unix.sysv386] SVR4 /bin/sh BUG Summary

rick@digibd.com (Rick Richardson) (05/29/91)

I recently posted the enclosed script which demonstrates a
bug in SVR4's Bourne shell.  With the help of the net,
it appears that the bug is not restricted to just one
architecture.  Failure has been reported on:

	AT&T SVR4 on i386
	HCI SVR4 on i386
	Commodore SVR4 on Amiga
	SVR4 on i860

-Rick

#
#	Demonstrates bug in SVR4 /bin/sh
#	Works OK with /bin/sh on SVR3 and XENIX
#	Works OK with /bin/ksh on SVR4
#
#	Should output the first line of /etc/passwd four times
#	Only does it three times on SVR4 and then hangs
#
#	Seems to be related to changing fd0 in a function
#
read_by_func() {
	exec 3<&0 0<$1
	read x
	echo $x
	exec 0<&3 3<&-
}

exec 3<&0 0</etc/passwd
read x
echo $x
exec 0<&3 3<&-

exec 3<&0 0</etc/passwd
read x
echo $x
exec 0<&3 3<&-

read_by_func /etc/passwd

# Gets stuck here with /bin/sh...
read_by_func /etc/passwd
-- 
Rick Richardson		Email: rick@digibd.com
Senior MTS		Fax: (612) 943-0803
DigiBoard, Inc.		Tel: (612) 943-5383

slootman@dri.nl (Paul Slootman) (05/30/91)

rick@digibd.com (Rick Richardson) writes:
>I recently posted the enclosed script which demonstrates a
>bug in SVR4's Bourne shell.  With the help of the net,
>it appears that the bug is not restricted to just one
>architecture.    ...
[deleted]

I just tried it on an ICL DRS6000 (Sparc) running SVR4 (uname -a
output: 'drs6000_V_4 dri6000 4.0 2.13 DRS 6000 Sparc').
No problems detected using /bin/sh, /bin/jsh, or /bin/ksh.

Paul.
-- 
 ----------------
:slootman@dri.nl : When you get to the point where you think that nothing
:+ 31 5496 88831 : is impossible, try pushing toothpaste back into a tube
 ----------------

urban@cbnewsl.att.com (john.urban) (05/30/91)

In article <1991May29.162012.25888@digibd.com> rick@digibd.com (Rick Richardson) writes:
>I recently posted the enclosed script which demonstrates a
>bug in SVR4's Bourne shell.  With the help of the net,
>it appears that the bug is not restricted to just one
>architecture.  Failure has been reported on:
>

I thought I had replied to you before, but perhaps I forgot or it got lost.

This BUG does NOT exist on:
AT&T UNIX System V/386 Release 4.0 Version 2.1.  Both KSH and SH work fine
on the example.

Sincerely,

John Ben Urban
>
>#
>#	Demonstrates bug in SVR4 /bin/sh
>#	Works OK with /bin/sh on SVR3 and XENIX
>#	Works OK with /bin/ksh on SVR4
>#
>#	Should output the first line of /etc/passwd four times
>#	Only does it three times on SVR4 and then hangs
>#
>#	Seems to be related to changing fd0 in a function
>#
>read_by_func() {
>	exec 3<&0 0<$1
>	read x
>	echo $x
>	exec 0<&3 3<&-
>}
>
>exec 3<&0 0</etc/passwd
>read x
>echo $x
>exec 0<&3 3<&-
>
>exec 3<&0 0</etc/passwd
>read x
>echo $x
>exec 0<&3 3<&-
>
>read_by_func /etc/passwd
>
># Gets stuck here with /bin/sh...
>read_by_func /etc/passwd