[comp.unix.wizards] A question of aliases...

dan@rna.UUCP (Dan Ts'o) (04/20/89)

	This has probably been answered a zillion times, but...

	Why doesn't the CSH alias:

	alias foo "echo $1 hello $2"

	give the expected results:

	% foo a b
	a hello b
	%

	Instead it gives:

	% foo a b
	hello a b
	%

	This is the result on 4.3BSD VAX, Ultrix 2.2 and some version of KSH.

	A friend wanted an alias of:

	% alias ff "find $1 -name $2 -print"

	but the best I could come up with was:

	% alias ff "find \!^ -name \!$ -print"

	Even \!1 and \!2 don't work (I guess they grab real events and not
alias args, but then why do \!^ and \!$ work ?).

	Please email responses. Thanks.


				Cheers,
				Dan Ts'o		212-570-7671
				Dept. Neurobiology	dan@rna.rockefeller.edu
				Rockefeller Univ.	...cmcl2!rna!dan
				1230 York Ave.		rna!dan@nyu.edu
				NY, NY 10021		tso@rockefeller.arpa
							tso@rockvax.bitnet

kai@uicsrd.csrd.uiuc.edu (04/21/89)

>/* Written 10:06 pm  Apr 19, 1989 by dan@rna.UUCP in uicsrd.csrd.uiuc.edu:comp.bugs.4bsd */
> Why doesn't the CSH alias:
>	alias foo "echo $1 hello $2"
> give the expected results:
>	% foo a b
>	a hello b
>				Dan Ts'o		212-570-7671
>				Dept. Neurobiology	dan@rna.rockefeller.edu
>				Rockefeller Univ.	...cmcl2!rna!dan

Try something like:
	alias foo 'set argv = ( \!* ); echo $1 hello $2'
This does what you want (on 4.3 BSD).


Patrick Wolfe  (pat@kai.com,  kailand!pat)
System Manager, Kuck & Associates, Inc.