Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site sequent.UUCP Path: utzoo!watmath!clyde!akgua!sdcsvax!sdcrdcf!hplabs!tektronix!ogcvax!sequent!merlyn From: merlyn@sequent.UUCP Newsgroups: net.unix Subject: Re: Bourne shell programming question... Message-ID: <499@sequent.UUCP> Date: Mon, 14-May-84 13:01:12 EDT Article-I.D.: sequent.499 Posted: Mon May 14 13:01:12 1984 Date-Received: Mon, 21-May-84 04:49:46 EDT References: <250@rna.UUCP> Organization: Sequent Computer Systems, Portland Lines: 63 > From: dan@rna.UUCP > Message-ID: <250@rna.UUCP> > Date: Tue, 8-May-84 16:06:31 PDT > > Hi, > I've just started to use the Bourne shell in non-trivial > command script writing and have run into a number of problems. I am > converting some shell scripts from an older shell (V6-like with variables). > In particular, > 1) How do you read a single line from /dev/tty (or an arbitrary file, > NOT stdin) and assign that line to a variable ? > 2) How do you arrange for a single instance of common shell code ? > The Bourne shell has no procedures and no goto statement. First, number 2. Can't, at least not without stashing it in a separate file and calling it as a subroutine (very icky). Also, they call up (at least) one more process. Time consuming on most Un*xes. Second, number 1. I agree that your solutions leave lots to be desired. Bourne himself in his (not real great) book "The Unix System", gives this flavor of a solution: exec 3<&0 &0 2>&1") Schwartz, esq. (merlyn@sequent.UUCP) (Official Legendary Sorcerer of the 1984 Summer Olympics) Sequent Computer Systems, Inc. (503)626-5700 (sequent = 1/quosine) UUCP: {decwrl,ogcvax,pur-ee,rocks34,shell,unisoft,vax135,verdix}!sequent!merlyn P.S. Unix is a trademark of some divested part of TPC. (Who owns that now?) P.P.S. I have no personal gripes with Bourne. I just happen to notice that some of the things that he does are a bit odd. "Pay no attention to the man behind the curtain."