On 2016-03-22 at 18:35, Russell Gadd wrote: > On 22/03/16 19:00, The Wanderer wrote:
>> How did you test? By launching a new terminal (with bash set as >> your default shell), by running the command 'bash' in an existing >> terminal, by logging all of the way out (to the main login prompt, >> if not to a full reboot) and then logging back in, or by running >> the command 'bash --login' in an existing terminal? >> >> In my testing just now, only the latter two of these four will pick >> up the new ~/.profile file; the other two seem to run the commands >> which were present in the file which their parent bash session >> used. (Strictly speaking I didn't test the full logout or reboot, >> but I fully expect that that would pick up the changes.) >> >> >> Also, at least on my system, ~/.bashrc is invoked only by being >> sourced from ~/.profile or ~/.bash_profile. Unless your system is >> configured fairly differently, if ~/.bashrc is getting run, that >> means that - per bash(1) - one of ~/.bash_profile, ~/.bash_login, >> or ~/.profile must be invoking it. > > I tested by rebooting each time. My ~/.bashrc is sourced from > ~/.profile which itself is sourced from .bash_profile, but neither of > them run the echo command I've added so I would assume the ~/.bashrc > which runs when I open a Mate terminal is started some other way. > > bash --login does invoke ~./bash_profile and hence ~./profile as the > echos are seen in the output file (in the expected order), but I > must admit the nature of login shells / non-login / interactive > shells, etc is a bit beyond my experience. I've never tried bash > --login before as I haven't previously come across it. Just as a stab in the dark: in a newly-launched terminal after a fresh reboot, with no other commands run yet, what does 'echo $0' say? There's a faint chance that your default shell isn't actually bash, which would explain what you're seeing. I don't think that's very likely, for multiple reasons, but it's easy enough to rule out. > Maybe what this is telling me is that I should run another script > from my "login" script by 'bash --login real_login_scriptfile' in > order to get these profiles to run first? I wouldn't advise that route, no. It might work, but it would be a kludge at best, not a real solution. Instead, assuming that the above test confirms that you are running bash in these cases, I'd start out by going all the way to the top of the stack and figuring out what scripts are calling what, to figure out how ~/.bashrc is getting invoked. Figuring that out should help figure out what's going on, which should help get the rest to make sense. Things to try include: find ~/ -type f -maxdepth 1 -name ".*" -exec grep bashrc \; grep -R bashrc /etc/bash* strace -f bash --login 2>/tmp/bash.strace [Ctrl-D] (then search the resulting file for mentions of .bashrc, and look above that to figure out which scripts were opened before opening .bashrc) This last is the most complicated and hardest to understand, and I'm pretty sure I haven't got the right strace command to get the most information out of it anyway, but it should be enough to get things started. You can also try searching the file for mentions of the profile files, just in case they show up directly. (They should, in fact.) -- The Wanderer The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man. -- George Bernard Shaw
signature.asc
Description: OpenPGP digital signature