bug-bash
[Top][All Lists]
Advanced

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

Re: Function visibility


From: Bob Proulx
Subject: Re: Function visibility
Date: Tue, 2 Oct 2007 10:57:16 -0600
User-agent: Mutt/1.5.13 (2006-08-11)

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.  It reads as if this is a suggestion to place
shell functions in a bashrc file and I wanted to clarify that that is
not the case.

Non-interactive scripts should not normally be reading system or
personal bashrc customization files.  Putting a function in a bashrc
would still not make it visible to scripts.  This of the problems that
scripts would have if user's aliases for ls='ls -F --color=always' and
rm='rm -i' were seen by scripts.  Script authors need a known stable
run environment.

In summary shell functions should be defined in the script or defined
in a file sourced by the script.

Bob




reply via email to

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