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

Re: Using aliases or functions in bash script



On Sat, 26 Jan 2008 17:12:56 +0000
Tzafrir Cohen <tzafrir@cohens.org.il> wrote:

> On Thu, Jan 24, 2008 at 03:55:51AM +0000, T o n g wrote:
> 
> > I'm wondering if you have read my OP or not. Read it again pls.
> 
> Yes I have. Use functions. Don't use aliases.
> 

On command-line:

function dt () {
	push +$1
}

In test.sh

#!/bin/bash

pwd
$(dt $(pwd))
cd /tmp
popd
pwd

./test.sh
Line 2 errors out.  I imagine the same thing happens with his attempt
to use his bashrc-defined functions in a script without defining them
again in the script.

IIUC he wants to know how to use already defined functions/aliases in a
shell script.

A possible way around would be to define the functions in .bashrc and
then source .bashrc, but I am curious myself as to how one would
achieve the other (using existing functions rather then defining them
again in a new script).

Regards,

Daniel

-- 
And that's my crabbing done for the day.  Got it out of the way early, 
now I have the rest of the afternoon to sniff fragrant tea-roses or 
strangle cute bunnies or something.   -- Michael Devore
GnuPG Key Fingerprint 86 F5 81 A5 D4 2E 1F 1C      http://gnupg.org
No more sea shells:  Daniel's Weblog    http://cshore.wordpress.com

Attachment: signature.asc
Description: PGP signature


Reply to: