Hi Bash users and experts,
I wanted to find the full path of a sourced script. I cannot use
something like `basename $0` as $0 points to $BASH. I came across
$BASH_SOURCE, which seems to do the trick. But I don't quite understand
how that translates from the following snippet from the info page (since
there are no functions involved here).
`BASH_SOURCE'
An array variable whose members are the source filenames where the
corresponding shell function names in the `FUNCNAME' array
variable are defined. The shell function `${FUNCNAME[$i]}' is
defined in the file `${BASH_SOURCE[$i]}' and called from
`${BASH_SOURCE[$i+1]}'
Is there a better alternative? If not, can someone help me understand
my specific case, when I'm not inside a function?
Thanks,
--
Suvayu
Open source is the future. It sets us free.