Full path of executing script in ksh?

Hello all,

Here's the scenario:

I've got a script, let's call it script1. This script invokes another script, which we'll call set_env, via the dot "." command, like so:

File: [script1]

#!/bin/ksh
#
region_id=DEV
. set_env ${region_id}

and so on. Script set_env sets up an execution environment for the remainder of script1 according to the value of the parameter (region_id) passed.

My question/problem is:

Let us assume that set_env resides in the same directory as script1. How can I ensure that set_env will be found by the shell, when the containing directory is not in the PATH, and is not the PWD at the time script1 was invoked? In other words, how can script1 tell the shell to look for set_env in whatever directory script1 happens to reside?

I understand that ${_} is supposed to return the full pathname of the script being executed, but when I try to use that in script1, it fails to return anything meaningful.

Any hints will be very much appreciated. Thanks!

#!/bin/ksh
#
thisFile="$(whence ${0})"
thisDir="${thisFile%/*}"

region_id=DEV
. "${thisDir}"/set_env ${region_id}

Thank you, that works just fine!