Bourne shell io redirection with <> -- what is it?

Richard Mathews lcc.richard at UCLA-LOCUS.ARPA
Thu Apr 25 02:19:33 AEST 1985


> > Does anyone know what the undocumented <> io redirection metacharacter
> > sequence in the bourne shell does?	Is it useful?
>
> What it does:
>	  redirects input from specified file but open() is called
>	  for read/write instead of read only
>
> Is it useful:
>	  Doubtful

Well, I managed to find a use for it.  It turns out that "more" tries
to READ STDERR! (yucch!), so I wanted to open stderr for read/write.
I discovered why this "feature" is undocumented.  It does not work.
I tried it on the Sys V.2, BSD 4.1, and BSD 4.2 Bourne shells.	On all
of these it only opened the file for read.

I took a look at the shell source.  When it sees this construct, it sets
a bit, IORDW, in its I/O structure.  Unfortunately, this bit never gets
tested.  When the shell goes to open the file, it will just end up falling
into the code it uses for ">filename".

As I side issue, if "more" cannot read stderr for any reason other than
EINTR, it exits WITHOUT SETTING THE TERMINAL MODES BACK!

Richard M. Mathews
Locus Computing Corporation			       lcc!richard at ucla-cs
					{ucivax,trwrb}!lcc!richard
	 {ihnp4,randvax,sdcrdcf,ucbvax,trwspp}!ucla-cs!lcc!richard



More information about the Comp.unix.wizards mailing list