Xref: utzoo comp.unix.shell:2218 comp.unix.wizards:25676 comp.unix.sysv386:8192 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!spool.mu.edu!cs.umn.edu!quest!digibd!rick From: rick@digibd.com (Rick Richardson) Newsgroups: comp.unix.shell,comp.unix.wizards,comp.unix.sysv386 Subject: SVR4 /bin/sh BUG Message-ID: <1991May18.195752.14842@digibd.com> Date: 18 May 91 19:57:52 GMT Article-I.D.: digibd.1991May18.195752.14842 Organization: DigiBoard Incorporated, Eden Prairie, MN Lines: 48 Here's a nasty little surprise I discovered when porting some Bourne shell code from SVR3 to SVR4. The tidbit below serves only to demonstrate the bug. The real code did something useful, at least it did on SVR3. :-) I checked UHC and AT&T flavors of SVR4. Don't know how many others have the bug. -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