Re: Using aliases or functions in bash script
On Wed, Jan 23, 2008 at 11:10:13PM +0000, T o n g wrote:
> Hi,
>
> 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:
my_alias() {
some command "$@"
}
Then you can freely use:
my_alias whatever extra parameters
--
Tzafrir Cohen | tzafrir@jabber.org | VIM is
http://tzafrir.org.il | | a Mutt's
tzafrir@cohens.org.il | | best
ICQ# 16849754 | | friend
Reply to: