Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cwjcc!tut.cis.ohio-state.edu!AUREL.CALTECH.EDU!bfox From: bfox@AUREL.CALTECH.EDU (Brian Fox) Newsgroups: gnu.bash.bug Subject: bash exports in declare Message-ID: <8907192051.AA12304@aurel.caltech.edu> Date: 19 Jul 89 20:51:34 GMT References: <8907191303.AA02701@dash.mitre.org> Sender: daemon@tut.cis.ohio-state.edu Reply-To: bfox@aurel.caltech.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 78 Date: Wed, 19 Jul 89 09:03:56 EDT From: barratt@dash.mitre.org (Jeff Barratt) Brian, Nice job on bash. We're running v1.02 on Sun 3's w OS4.01. Problem: "declare -x" and "typeset -x" do NOT seem to export. A separate "export vars" is required. Thanks. This turned out to be a simple problem and fix. In builtins.c, function declare_internal (), the lines which read else if (*t == 'x') *flags |= att_exported, t++; needs to have "array_needs_making = 1" added to it. else if (*t == 'x') *flags |= att_exported, t++, array_needs_making = 1; This tells bash that the list of exported variables has changed, and needs to be recalculated. Question: Could you elaborate on the startup execution of default files. It appears that initial login runs "~/.bash_profile", and subsequent shells run "~/.bashrc". What about "~/.bash_(login,logout)"? Sure, and since you aren't the first to ask about this, I'll take a little time to make sure I document it clearly. The follwing is the way that Bash 1.03 (pre-release) does it. Earlier releases have the exception of not having the "ENV" variable, and of executing ~/.bashrc for shell scripts. When and how bash executes login, rc, and logout files. Login shells: On login: if /etc/profile exists, source it. if ~/.bash_profile exists, source it, else if ~/.bash_login exists, source it, else if ~/.profile exists, source it. On logout: if ~/.bash_logout exists, source it. Non-login interactive shells: On startup: if ~/.bashrc exists, source it. Non-interactive shells: On startup: if the environment variable "ENV" in non-null, source the file mentioned there. So, typically, your ~/.bash_profile file contains the line if [ -f ~/.bashrc ]; then source ~/.bashrc; fi after (or before) any login specific initializations. You can tell if a shell is interactive or not from within your ~/.bashrc file by examining $PS1; it is unset in non-interactive shell, and set in interactive shells. Thus: if [ "$PS1" = "" ]; then echo This shell is not interactive else echo This shell is interactive fi Thanks, Brian Fox