Aliases, functions and shell scripts

Brandon Allbery allbery at ncoast.UUCP
Fri Dec 6 10:34:45 AEST 1985


Expires:

Quoted from <1453 at lumiere.UUCP> ["Re: Bourne shell modifications, past and future"], by davest at 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 at Case.CSNet (ncoast!allbery%Case.CSNet at 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...)



More information about the Comp.unix.wizards mailing list