ql_get_latest(){
. "$BASH_SOURCE";
}
export -f ql_get_latest;
when I run bash
, I drop into a shell:
and then when I run ql_get_latest
I get:
bash: environment: No such file or directory
anybody know what that's about?
BASH_SOURCE
(or specifically, the element at index 0 of that array) is the name of the file where a function definition occurs. Since your shell inherits ql_get_latest
from its parent, the name of the "source file" is set to environment
. You can see this (and another special case) if you simply echo the value of the variable from the function.
$ foo () { echo "$BASH_SOURCE"; }
$ foo
main
$ export -f foo
$ bash
$ foo
environment
In your case, you are attempting to source the file named environment
, which doesn't exist. (And if it did, it wouldn't necessarily be related to ql_get_latest
in any way.)