Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!linus!philabs!cmcl2!seismo!brl-tgr!tgr!lcc.brian@UCLA-LOCUS.ARPA From: lcc.brian@UCLA-LOCUS.ARPA (Brian Horn) Newsgroups: net.unix-wizards Subject: re: read/write I/O redirection for sh Message-ID: <10906@brl-tgr.ARPA> Date: Wed, 22-May-85 05:45:24 EDT Article-I.D.: brl-tgr.10906 Posted: Wed May 22 05:45:24 1985 Date-Received: Fri, 24-May-85 20:40:46 EDT Sender: news@brl-tgr.ARPA Lines: 42 A while ago someone asked what the redirection syntax "<>" was for and whether it was useful. Since it didn't work, it certainly wasn't useful, however the fix below may be found to be useful (Note: this patch is for the bourne shell distributed with sysV release 2. It should be very similiar for other versions of sh.) sh/service.c (approx. line 65) . . . else if (iof & IOMOV) { if (eq(minus, ion)) { fd = -1; close(ioufd); } else if ((fd = stoi(ion)) >= USERIO) failed(ion, badfile); else fd = dup(fd); } + else if (iof & IORDW) { + if ((fd = open(ion, 2)) < 0) + failed(ion, badopen); + } else if ((iof & IOPUT) == 0) fd = chkopen(ion); . . . This patch will open the file after the "<>" read/write defaulting to file descriptor 0. (Of course, as with all sh redirection you may proceed it with a file descriptor number.) Brian D. Horn Locus Computing Corporation lcc!brian@ucla-cs {ucivax,trwrb}!lcc!brian {ihnp4,randvax,sdcrdcf,ucbvax,trwspp}!ucla-cs!lcc!brian