home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / gnu / bash / bug / 704 < prev    next >
Encoding:
Text File  |  1992-12-15  |  3.5 KB  |  107 lines

  1. Newsgroups: gnu.bash.bug
  2. Path: sparky!uunet!usc!cs.utexas.edu!uwm.edu!spool.mu.edu!agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!hpfcla.fc.hp.com!rwp
  3. From: rwp@hpfcla.fc.hp.com (Bob Proulx)
  4. Subject: Re: Won't read .bashrc
  5. Message-ID: <BzBn6C.KnB@fc.hp.com>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: Fort Collins, CO
  8. References: <jtarr.724364430@husc8>
  9. Distribution: gnu
  10. Date: Tue, 15 Dec 1992 22:15:48 GMT
  11. Approved: bug-bash@prep.ai.mit.edu
  12. Lines: 93
  13.  
  14. In article <jtarr.724364430@husc8> you wrote:
  15. : bash doesn't seem to read my .bashrc file when I login.  It does read
  16. : my .bash_profile and .profile files, but not my .bashrc.
  17.  
  18. The solution is to source your .bashrc file in your .profile.  This is
  19. different than either ksh or csh but I like the new behavior.  It
  20. gives more control over the problem.
  21.  
  22.     . $HOME//.bashrc
  23.  
  24. Following is just more explaination so skip on if you already know this.
  25.  
  26. >From the manual:
  27.       Login shells:
  28.         On login:
  29.               if /etc/profile exists, source it.
  30.  
  31.               if ~/.bash_profile exists, source it,
  32.                 else if ~/.bash_login exists, source it,
  33.                   else if ~/.profile exists, source it.
  34.  
  35.         On logout:
  36.               if ~/.bash_logout exists, source it.
  37.  
  38.       Non-login interactive shells:
  39.         On startup:
  40.               if ~/.bashrc exists, source it.
  41.  
  42.       Non-interactive shells:
  43.         On startup:
  44.               if the environment variable ENV is non-null, expand
  45.            it and source the file it names.
  46.  
  47. So the manual says that bash does not read the .bashrc file if the
  48. shell is a login shell.  I suggest using one .profile for ksh and
  49. bash.  In the .profile source the .bashrc file for bash.
  50.  
  51. I run different shells on different machines because I can't always
  52. install my favorite shell everywhere.  My .profile uses a case
  53. statement to switch between them.  I post it only as an example.
  54.  
  55. case "$SHELL" in
  56. *bash)
  57.   # bash only vars
  58.   export SHELL=/bin/bash
  59.   export HISTFILE=$HOME//.bash_history
  60.   export FIGNORE="~:.o:.a:.h"
  61.   export auto_resume=1
  62.   export no_exit_on_failed_exec=1
  63.   . $HOME//.bashrc
  64.   unset ENV  # Just in case.
  65.   ;;
  66. *ksh)
  67.   # ksh only vars
  68.  
  69.   # From the KornShell book.  Does not work with ksh86. :-(
  70.   # export ENV='${FILE[ (_$-=0) + (_=1) - _${-%%*i*} ]}'
  71.   # Hack to only load .kshrc if interractive.  Works with ksh86
  72.   export ENV='${START[(_$-=1)+(_=0)-(_$-!=_${-%%*i*})]}'
  73.   export START=$HOME//.kshrc
  74.  
  75.   export SHELL=/bin/ksh
  76.   export HISTFILE=$HOME//.sh_history
  77.   ;;
  78. esac
  79.  
  80. Why I use two slashes:  I always use $HOME//filename because on Apollo
  81. and apparently OSF you can specify //machinename/filename.  This is
  82. allowed by POSIX which I think says that leading 1 or 3-n slashes
  83. equal one slash and 2 slashes might mean anything.  If I use bash for
  84. root and have root's home in / then $HOME will be a single slash.
  85. $HOME/file will become //file which might be interpreted as a machine
  86. name instead.  Whew!
  87.  
  88. : As a result my PATH is not set correctly which just wreaks havok
  89. : later.
  90.  
  91. I personally don't like setting PATH in the rc file.  Set it in
  92. your .profile and let all other shells inherit the environment.  Its
  93. faster anyway.  My suggestion is to put as little as possible in
  94. the .bashrc file.
  95.  
  96. : I'm switching to bash from csh.  I'm only a bash beginner so I
  97.  
  98. We all have to start somewhere!  I think you have made a fine choice.
  99.  
  100. Bob Proulx
  101. rwp@fc.hp.com
  102.  
  103. Not an official statement of my employer, its just my opinion.  I
  104. don't even have official opinions unless I say so.
  105.  
  106.  
  107.