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

Re: [OT] Using aliases or functions in bash script




On 27 Jan 2008, at 14:08, T o n g wrote:

On Sat, 26 Jan 2008 23:40:02 +0000, William Pursell wrote:

An advanced bash alias expansion question --
How can I use my aliases or functions in my bash script?

PS. I even tried the following but it didn't work either:

$ bash -O expand_aliases -c '. ~/.bashrc; (rd /tmp/ttt; alias rd; dt bin; type dt)'

The point of my previous response, which I complete failed to
make (and in fact didn't realize until after I'd sent it...)
is that your .bashrc probably includes a line of the form:
[ -z "$PS1" ] && return

So that the bashrc returns prior to defining any aliases. . .

OMG, that's EXACTLY the reason!

NEARLY THREE YEARS[1] has the question been haunting me, and you solve it,
by identifying my culprit line via looking through a crystal ball :-).

may I humbly suggest you look at 'set -x' (xtrace), which can also be used on a shell's '#!' line, which will echo commands and thus you can see what is (or in some cases is not) actually happening? there's similar options available for csh too


Reply to: