locating a sourced file - Questions

This is a discussion on locating a sourced file - Questions ; How can a sourced file determine its location?...

+ Reply to Thread
Results 1 to 4 of 4

Thread: locating a sourced file

  1. locating a sourced file

    How can a sourced file determine its location?

  2. Re: locating a sourced file

    On Thursday 31 August 2006 11:52, Angel Tsankov
    wrote in comp.os.linux.misc:

    > How can a sourced file determine its location?


    Source files cannot determine anything - they are not executables.
    --
    Robert HULL

    Archival or publication of this article on any part of thisishull.net
    is without consent and is in direct breach of the Data Protection Act

  3. Re: locating a sourced file

    On 2006-08-31, Angel Tsankov wrote:
    > How can a sourced file determine its location?


    This is almost always unnecessary; the reasons why have been
    explained in this and other newsgroups time and time again. The
    question is usually asked about an executed script rather than a
    sourced one, and that is somewhat easier to answer.

    If you are using bash, try ${BASH_SOURCE[0]}. If that doesn't
    contain the full path, the script is in (or relative to) the
    current directory.

    --
    Chris F.A. Johnson, author |
    Shell Scripting Recipes: | My code in this post, if any,
    A Problem-Solution Approach | is released under the
    2005, Apress | GNU General Public Licence

  4. Re: locating a sourced file

    >> How can a sourced file determine its location?
    >
    > If you are using bash, try ${BASH_SOURCE[0]}. If that doesn't
    > contain the full path, the script is in (or relative to) the
    > current directory.


    Thanks!

+ Reply to Thread