[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 09:01:07 +0100 |
User-agent: |
Mutt/1.5.16 (2007-06-11) |
On Mon, Oct 01, 2007 at 04:43:15PM -0700, retiredff wrote:
>
> I have several functions in my /etc/profile (Mac OSX 10.4.9). I can use the
> functions at the commandline, however inside of scripts I receive an error.
> I'll use an example of a function I have called cecho that echo's a string
> in a color that is passed in $2, $1 has the string:
>
> ./maintenance: line 27: cecho: command not found
>
> If I run this from the command line, it works fine. What am I doing wrong?
> I also have the same problem with any alias commands I use inside of
> scripts. If I type 'set' on the CLI it lists all of the functions. Should I
> use export function-name?
[...]
/etc/profile ~/.profile are not shell customization files, they
are your login session customization file. They are read once
only upon login, so you may only put there customization that
will be affecting all future processes (no necessarily shells)
in your session.
bash's customization files are ~/.bashrc and depending on how
bash was compiled /etc/bashrc or /etc/bash.bashrc... see your
manual.
bash has a bug/misfeature in that the login shells, even when
interactive, don't load the bashrc.
To work around that, you have to do things like this in
/etc/profile:
if [ -n "$BASH_VERSION" ]; then
case $- in
*i*)
if [ -f /etc/bashrc ] &&
[ -r /etc/bashrc ]; then
. /etc/bashrc
fi;;
esac
fi
And do something similar in your ~/.profile for your ~/.bashrc.
--
Stéphane
- Function visibility, retiredff, 2007/10/01
- Re: Function visibility,
Stephane Chazelas <=
- Re: Function visibility, Bob Proulx, 2007/10/02
- Message not available
- Re: Function visibility, Stephane Chazelas, 2007/10/02
- Re: Function visibility, Bob Proulx, 2007/10/02
- Message not available
- Re: Function visibility, Stephane Chazelas, 2007/10/02
- Re: Function visibility, Matthew Woehlke, 2007/10/02
- Re: Function visibility, Bob Proulx, 2007/10/02