Re: Using aliases or functions in bash script
On Wed, Jan 23, 2008 at 11:10:13PM +0000, T o n g wrote:
> A (adv) bash alias expansion question --
> How can I use my aliases or functions in my bash script?
> I have the following alias and function defined in my ~/.bashrc:
> $ alias rd
> alias rd='rmdir'
> $ type dt
> dt is a function
> dt ()
> pushd +$1
> How can I use them in my script?
> Looking through the man pages, I think the following content is related
> to my question:
> Aliases are not expanded when the shell is not interactive, unless the
> expand_aliases shell option is set using shopt.
So just use functions. They are really handier. Here's a function that
replaces an alias:
some command "$@"
Then you can freely use:
my_alias whatever extra parameters
Tzafrir Cohen | email@example.com | VIM is
http://tzafrir.org.il | | a Mutt's
firstname.lastname@example.org | | best
ICQ# 16849754 | | friend