Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site ncoast.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!cwruecmp!hal!ncoast!allbery From: allbery@ncoast.UUCP (Brandon Allbery) Newsgroups: net.unix,net.unix-wizards Subject: Aliases, functions and shell scripts Message-ID: <909@ncoast.UUCP> Date: Thu, 5-Dec-85 19:34:45 EST Article-I.D.: ncoast.909 Posted: Thu Dec 5 19:34:45 1985 Date-Received: Sun, 8-Dec-85 02:56:27 EST References: <1943@gatech.CSNET> <10@druri.UUCP> <21@pixdoc.UUCP> Reply-To: allbery@ncoast.UUCP (Brandon Allbery) Followup-To: net.unix Organization: Cleveland Public Access UNIX, Cleveland, OH Lines: 39 Xref: watmath net.unix:6556 net.unix-wizards:15996 Expires: Quoted from <1453@lumiere.UUCP> ["Re: Bourne shell modifications, past and future"], by davest@lumiere.UUCP (Dave Stewart)... +--------------- | I think most people who have both aliases and functions available | use aliases as command-name macros and shell functions like programming | language functions. Well, the analogy isn't perfect, since one also | has shell scripts to act as "functions", but I believe the concept is | transferable. Do I want to chuck out macros because I have functions | available? Heck no. +--------------- The analogy you want is: Shell C ------------ ------------ alias hi=echo "hello, $1" #define hi(who) printf("hello, %s\n", who) function hi { hi(who) echo "hello, $1" char *who; { } printf("hello, %s\n", who); } cat > hi; chmod +x hi if (fork()) echo "hello, $1" wait(0); ^D else execlp("hi", "hi", who, 0); Take your pick. As usual, each has advantages and disadvantages. I don't think cpp macros will soon disappear. . . --Brandon -- Lord Charteris (thurb) ncoast!allbery@Case.CSNet (ncoast!allbery%Case.CSNet@CSNet-Relay.ARPA) ..decvax!cwruecmp!ncoast!allbery (..ncoast!tdi2!root for business) 6615 Center St., Mentor, OH 44060 (I moved) --Phone: +01 216 974 9210 CIS 74106,1032 -- MCI MAIL BALLBERY (WARNING: I am only a part-time denizen...)