Calling shell functions from another shell script

Hi,

I have a query ..
i have 2 scripts say 1.sh and 2.sh
1.sh contains many functions written using shell scripts.
2.sh is a script which needs to call the functions definded in 1.sh
function calls are with arguments.
Can some one tell me how to call the functions from 2.sh?

Thanks in advance.
JS

I have done a bit more research.
I know this is not possible especially with arguments. but still there should be a way out ..

JS

1.sh:

#!/bin/ksh
fun1() {
  typeset arg1="${1}"
  echo "in 1.sh::fun1 arg1->[${arg1}]"
}

2.sh:

#!/bin/ksh
echo "in 2.sh"
. 1.sh

fun1 "foo"

:)Thank you vgersh99 !!

There is a better way of doing what you want to do using FPATH and/or autoload

For example, suppose you create the following directory within your home directory and put your function scripts in this directory. The filename should be the function name.

mkdir ~/.kshfunctions

In your .kshrc file, define the FPATH variable to point to that directory:

export FPATH=~/.kshfunctions

Functions will then be loaded on an as needed basis and results in faster script startup. To get a listing of which functions are actually currently loaded, just type 'functions' at the prompt. Use whence to find a function.

#!/usr/bin/ksh93
echo "in 2.sh"
fun1 "foo"
# fun1
function fun1
{
  print "In function fun1 arg1->[$1]"
}
$./2.sh
in 2.sh
In fun1 arg1->[foo]

That is limited to the Korn shell and will not work in any other shell.

Yes, I agree, it is limited to ksh93.