[net.unix-wizards] Bourne shell io redirection with <> -- what is it?

ned@SCINEWS.UUCP (Ned Robie) (03/30/85)

Does anyone know what the undocumented <> io redirection metacharacter
sequence in the bourne shell does?  Is it useful?

-- Ned Robie, SCI Systems, RTP

mike@enmasse.UUCP (Mike Schloss) (04/04/85)

> 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

					Mike Schloss

gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (04/06/85)

> Does anyone know what the undocumented <> io redirection metacharacter
> sequence in the bourne shell does?

It opens the subsequently-named file in mode 2 (read+write).

> Is it useful?

I've never found a reason to use it.

lcc.richard@UCLA-LOCUS.ARPA (Richard Mathews) (04/24/85)

> > 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@ucla-cs
					{ucivax,trwrb}!lcc!richard
	 {ihnp4,randvax,sdcrdcf,ucbvax,trwspp}!ucla-cs!lcc!richard