Problem with "read" in /bin/sh

Brandon S. Allbery allbery at NCoast.ORG
Fri Nov 10 11:46:03 AEST 1989


As quoted from <4094 at phri.UUCP> by roy at phri.UUCP (Roy Smith):
+---------------
| 	Why do I get "illegal io" when I do "read x < /dev/tty" in a shell
| file under MtXinu 4.3BSD/NSF on a Vax-11/750?  It works fine under
| SunOS-3.5.2 on a 3/50.  It doesn't seem to matter if I use the generic
| /dev/tty or the specific pseudo-tty I'm on.  For example:
+---------------

The V7-vintage /bin/sh, from which 4.xBSD sh is derived, can only redirect
built-ins if they are executed in a subprocess.  Thus, you can not redirect
the "read" command, and redirecting into or out of a loop causes that loop to
execute in a subshell as if you enclosed it in ().

The System V /bin/sh, which was picked up by Sun, does some trickery with
stashing the shell's own stdin/stdout/stderr elsewhere via dup2() (actually,
fcntl(F_DUPFD), but...), in order to allow built-in commands to be redirected
without the shell losing the undirected fd's.

++Brandon
-- 
Brandon S. Allbery    allbery at NCoast.ORG, BALLBERY (MCI Mail), ALLBERY (Delphi)
uunet!hal.cwru.edu!ncoast!allbery ncoast!allbery at hal.cwru.edu bsa at telotech.uucp
*(comp.sources.misc mail to comp-sources-misc[-request]@backbone.site, please)*
*Third party vote-collection service: send mail to allbery at uunet.uu.net (ONLY)*
>>>	     The *.aquari* debate: news.groups gone news.playpen	    <<<



More information about the Comp.unix.wizards mailing list