Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I run a shell (M-x shell) in Emacs.app, the shell spawned doesn't read (or more specifically, source), /etc/profile during initialization (I have a lot of shell customizations located there).

I've got the path variable set in ~/.MacOSX/environment.plist as is necessary to get Emacs.app to read $PATH, so I have made one of the necessary adaptations to accommodate Emacs to OS X. This doesn't seem to have anything to do with the PATH variable, but rather has to do with the initialization of the shell itself.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Ok, here's what I did to solve the problem. It is based an answer to this question from StackOverflow, which I found after mixing up my search terms a little bit on Google. I added the following line to .bashrc:

source /etc/profile

Everything works as it should now.

EDIT: Why the Problem Occurs

I found why you have to explicitly force the BASH shell to read /etc/profile rather than have it read on invocation. Here is the relevant section from the BASH manual (man bash):

When an interactive shell that is not a login shell is started, bash reads and executes commands from ˜/.bashrc, if that file exists. This may be inhibited by using the −−norc option. The −−rcfile file option will force bash to read and execute commands from file instead of ˜/.bashrc.

One can infer from the way this is written (and what it says about how to invoke login shells before this), is that shell.el does not invoke a login shell. I've looked for evidence of this in shell.el and it seems to be true, BASH is invoked with the -i flag (interactive) but not the --login flag. Non-login shells do read .bashrc, so this is why you can work around the problem by putting source /etc/profile into .bashrc.

share|improve this answer
    
great stuff, it got my .bashrc working again. –  Yar Mar 31 '10 at 9:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.