Path: utzoo!censor!geac!jtsv16!uunet!cs.utexas.edu!wuarchive!mailrus!cwjcc!hal!ncoast!allbery From: allbery@NCoast.ORG (Brandon S. Allbery) Newsgroups: comp.unix.wizards Subject: Re: Problem with "read" in /bin/sh Message-ID: <1989Nov10.004603.1206@NCoast.ORG> Date: 10 Nov 89 00:46:03 GMT References: <4094@phri.UUCP> Reply-To: allbery@ncoast.ORG (Brandon S. Allbery) Followup-To: comp.unix.wizards Organization: North Coast Public Access UN*X, Cleveland, OH Lines: 25 As quoted from <4094@phri.UUCP> by roy@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@NCoast.ORG, BALLBERY (MCI Mail), ALLBERY (Delphi) uunet!hal.cwru.edu!ncoast!allbery ncoast!allbery@hal.cwru.edu bsa@telotech.uucp *(comp.sources.misc mail to comp-sources-misc[-request]@backbone.site, please)* *Third party vote-collection service: send mail to allbery@uunet.uu.net (ONLY)* >>> The *.aquari* debate: news.groups gone news.playpen <<<