functions

I have korn shells where I want to create a function passing $1 to a function , determine my $STAT_ENV value, set the paths and return
the paths for STATSH,STATPRM,STATSQR,STATSQL,STATCTL TO BE USED IN THE UNIX SCRIPT THE CALLED THE fucnction in the first place.

Can someone tell me the best way to do this. It will be used in my production env.

# this would be my function
STAT_ENV=`echo "$1" | cut -c6-6`
echo "$2 $STAT_ENV"
> $logfile
if [[ "$STAT_ENV" = "e" ]];
then
SHELL=shd
PARMS=prmd
SQR=sqrd
PAR=pard
SQL=sqld
CTL=ctld;
elif [[ "$STAT_ENV" = "i" ]];
then
SHELL=shi
PARMS=prmi
SQR=sqri
PAR=pari
SQL-sqli
CTL=ctli;
elif [[ "$STAT_ENV" = "u" ]];
then
SHELL=shu
PARMS=prmu
SQR=sqru
PAR=paru
SQL=sqlu
CTL-ctlu;
else
SHELL=shp
PARMS=prmp
SQR=sqr
PAR=par
SQL=sql
CTL=ctl;
fi
#
STATSH=/first/apps/$SHELL
STATPRM=/first/apps/$PARMS
STATSQR=/first/apps/$SQR
STATSQL=/first/apps/$SQL
STATCTL=/first/apps/$CTL

Use CODE tags please, my eyes hurt ;9

This could look like

...
get_it()
{
     STAT_ENV=`echo "$1" | cut -c6-6`
}

set_1()
{
     SHELL=shd
     PARMS=prmd
     SQR=sqrd
     PAR=pard
     SQL=sqld
     CTL=ctld;
}

set_2()
{
     ...
}
...   # define some more

check_it()
{
     case $STAT_ENV in
           e)     set_1;;
           i)     set_2;;
           ...
           *)     echo "Hey, somebody missed handing over a parameter!"
                  exit 1;;
}

# then just call them to your needs:

set_1
set_2
set_3
set_4
get_it $1
check_it

exit 0

So it will be very modular for any future needs or changes.

I think I have it. decalrte all of these in a separate shell script, lets say function.sh

in my parent shell script insert

. function.sh

then all are avaialble and callable.