[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: aliases or functions--which to use?



On Sun, Sep 22, 2002 at 09:42:51PM -0400, alex wrote:
> But, can someone explain why 'functions' should be used instead of  
> 'aliases' ? 

Well, there are a few reasons related to the rules on exactly when alias
definitions are evaluated and when substitution is done, but the only
real-world situation I can think of where that would be an issue is if
you mixed functions and aliases (aliases defined inside a function won't
actually be available until after the function exits). And you have to
be a little more careful about shell wildcard and variable expansion in
an alias, but as long as you think about what you're doing you'll
probably never have a problem. You're not doing any of that stuff.

For simple things, aliases are usually faster and easier. Use them
unless you see a reason not to. Some people like functions better than
aliases, just like some people like C shells better than Bourne shells.
I wouldn't be surprised if at least some of the "experts" who told you
to use functions were just parroting what they read in the bash
documentation (or something similar).

-- 
Michael Heironimus



Reply to: