Chuck Remes wrote: > Some scripts like rvm (rvm.beginrescueend.com) need to run at the > tail end of the login process to tack on more data to PATH or set > other environment variables (think of it as a post-login > hook). These kinds of scripts fail to execute with the code above.
Thank you for the report. But I think you are misunderstanding the design of what scripts are executed at what times. The .bashrc file is sourced by interactive shells that are not login shells. This is the place to put customizations to the interactive environment. Normal non-interactive scripts do not source the file. Therefore if you have added commands to the end of the .bashrc file they will be sourced along with everything else when an interactive shell is started. If you have modified PATH there then you should be able to see that modification in your interactive environment. Login scripts source the .bash_profile (or .profile) and not not automatically source the .bashrc. But the .bashrc is typically sourced in the .bash_profile and therefore its effects are seen by login shells too. Non-interactive scripts do not source the .bashrc file. Therefore even if you made that change you wouldn't see them source the file. And with good reason since most aliases placed there are for interactive command line use and would break scripts. For example imagine the effect on a non-interactive batch script if an alias for rm='rm -i' were imposed upon them. Of course if you set $BASH_ENV (or $ENV) then bash sources it. It is really a ksh compatibility feature. But IMNHO you shouldn't do that. And if you do then you are already modifying the environment scripts and are of course free to make other modifications. > Here's an alternate method to perform the interactive session check, > which accomplishes the same effect in a much safer manner. > > # Check for an interactive session > if [[ ! -z "$PS1" ]] ; then > alias ls='ls --color=auto' > PS1='[...@\h \W]\$ ' > fi > > This allows scripts at the end of the .bashrc to be sourced/executed > under all normal conditions, as well as sourcing of .bashrc from > scripts. Since $HOME/.bashrc is your personal script you may modify it as you desire. I dare say that most users customize that file. Certainly most software distributions making use of GNU bash and packaging it for others modify that file. You are certainly free to make any modification there. You don't need an upstream change to do this. Bob
