Discussion:
locating a sourced file
(too old to reply)
Angel Tsankov
2006-08-31 10:52:30 UTC
Permalink
How can a sourced file determine its location?
Robert Hull
2006-08-31 12:23:56 UTC
Permalink
On Thursday 31 August 2006 11:52, Angel Tsankov
Post by Angel Tsankov
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
Chris F.A. Johnson
2006-08-31 13:15:03 UTC
Permalink
Post by Angel Tsankov
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 | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
Angel Tsankov
2006-08-31 14:33:17 UTC
Permalink
Post by Chris F.A. Johnson
Post by Angel Tsankov
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!

Continue reading on narkive:
Loading...