bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Function visibility


From: Stephane Chazelas
Subject: Re: Function visibility
Date: Tue, 2 Oct 2007 19:36:27 +0100
User-agent: Mutt/1.5.16 (2007-06-11)

On Tue, Oct 02, 2007 at 10:57:16AM -0600, Bob Proulx wrote:
> Stephane Chazelas wrote:
> > To work around that, you have to do things like this in
> > /etc/profile:
> > ...
> > And do something similar in your ~/.profile for your ~/.bashrc.
> 
> While that is normal to do to configure interactive sessions the
> original question was where should shell functions be placed for use
> by scripts.  I think the above answer is a good answer but to a
> different question.
[...]

Oops, I had indeed missed that important part of the discussion,
you're completely right.

However note that the file pointed to by the BASH_ENV
environment variable is sourced even by non-interactive shells
(as long as bash is not called as "sh" or with --posix or with
POSIXLY_CORRECT or SHELLOPTS=posix in its environment)
So, putting function definitions in /some/file will make those
function available to all non-posix bash instances that receive
BASH_ENV=/some/file in their environment.

Now, I'd agree with you you probably don't want to do that, and
the most sensible thing is to source your shell function library
file from your script.

-- 
Stéphane




reply via email to

[Prev in Thread] Current Thread [Next in Thread]