Subject: Re: Shell initialization
To: NetBSD help <netbsd-help@netbsd.org>
From: Marinier, M. Claude, G. <claude.marinier@dreo.dnd.ca>
List: netbsd-help
Date: 01/12/2000 10:33:22
Alex,

Thanks for your reply.

On Wed, 12 Jan 2000, Alexander Sorg wrote:
> "Marinier, M. Claude, G." wrote:
> > How does one setup the various shell initialization files? I have not
> > found much about this.
> Look in the manpage of the shell. There should be a description of the
> different startup-files.

There is a reasonable description. I was confused by incorrect examples
and by the differences between sh and bash. I read the man pages again
more carefully, did some experimentation, and made a lot of progress.

One of the files I picked-up somewhere is a /etc/profile that executes
~/.bash_login. This is wrong because bash does that by itself.

By the way, root's .profile dated 1999/04/19 does not define ENV. This
means that hup() would not defined in an interactive sub-shell. This seems
odd to me. Why was it done this way?

> > I have one specific problem: some configure scripts fail because of my
> > 'ls' alias. I use sh and bash. The issue is what goes in the /etc/profile,
> > the ~/.bash_login (or ~/.profile), and the ~/.bashrc files.
> In the /etc/profile file goes global (for all users) stuff. The
> dot-files in the user dirs are of course user-specific.
> To prevent things like your ls-alias from interfering with scripts, you
> should write an if-clause in your .profile, so that these aliases are
> only assigned in interactive sessions. I just have an example how this
> is done in csh:
> #-------- csh example --------
> if ($?prompt) then
>         # An interactive shell -- set some stuff up
>         set filec
>         set history = 1000
> endif
> #-------- csh example --------
> I don't know yet enough about sh to translate it apropriately.

The concept applies nonetheless to sh. I need to differenciate between
interactive and non-interactive invocations when dealing with sh.

On the other hand, bash reads ~/.bashrc for interactive shells and it
reads the file specified in BASH_ENV for non-interactive shells.

Thanks, I have made a lot of progress with this. Ignoring the examples I
saw and concentrating on the man pages made the difference.

--------------------
Claude Marinier, Information Technology Group    claude.marinier@dreo.dnd.ca 
Defence Research Establishment Ottawa (DREO)    (613) 998-4901  FAX 998-2675
3701 Carling Avenue, Ottawa, Ontario  K1A 0Z4         http://www.dreo.dnd.ca