The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 07-01-2009
Al262 Al262 is offline
Registered User
  
 

Join Date: Jul 2009
Location: Pittsburgh, PA
Posts: 6
Thumbs down KSH - Sourced file location

The sample scripts below, I am looking for the location of the sourced b.sh file. The b.sh file is source by multiple files, so it is not feasible to rely on a "global" variable or passed argument. Is there any way to determine the location of b.sh within b.sh?

a.sh

Code:
 
#!/bin/ksh
echo "a: <$0>"
ScriptDir=`dirname $0`
. ${ScriptDir}/b.sh


b.sh

Code:
 
#!/bin/ksh
WhereAmI="????"
echo "b: <$0> ${WhereAmI}"