Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > trouble setting my shell environment

trouble setting my shell environment
Thread Tools
Fresh-Faced Recruit
Join Date: Dec 2002
Status: Offline
Reply With Quote
Dec 23, 2002, 01:46 AM
 
hi,

i'm having a bit of trouble getting Terminal to take my environment settings when i launch a new login shell.

i've read some of the posts on this board having to do with setting up your terminal environment, and i've generally come to the conclusion that as with most things unix, there are a number of ways to get the job done.

anyway, for the moment i'd like to try to set up Terminal to take the environment settings as recommended in /usr/share/tcsh/examples (even tho i'm kind of partial to bash & zsh). i followed the instructions in the README, and when i start a new shell, it shows up for a second and then disappears. guess there's someting in one of those files that the system doesn't like!

after i undid those changes, next i tried following some advice in one of the threads i just read here. basically, setting up a user-specific environment (supposedly sourced by the system when a new login shell is spawned) inside ~/Library/init/tcsh, in the *.mine files. Terminal, however, didn't seem to take these settings. nothing bad happened per se, except for the fact that, well, nothing happened!

finally, i said to hell with tcsh altogether and went for my old standby, bash. i basically i just created a .bashrc in ~ with the classpath settings and such that i want. this does the trick, but only if i manually source it after firing up the login shell.

given that everything else i do with my mac is so easy and so elegant, there's got to be a simple way for Terminal to take my environment settings when i fire up a new login shell. anybody out there care to lend their expertise toward my rather n00bie query?

cheers.

ps - within the scope of these environment settings files, is there a meaningful difference between using 'export' and 'set'/'setenv'? how about $HOME vs ${HOME}? i've seen both but i'm not sure exactly what the distinction is. thanks!
     
JNI
Forum Regular
Join Date: Oct 2002
Location: Left Coast
Status: Offline
Reply With Quote
Dec 25, 2002, 07:06 AM
 
You might try setting the 'Don't close window' shell setting in the Terminal Window Settings dialog so that the window will stay open even if it exits for an unknown reason. Then you might have more clues as to why the shell is exiting.

What version of the OS are you using? There was a typo in the tcsh/examples/aliases file in 10.2.1 (or was it 10.2.2?) where the TERM_PROGRAM variable is being referenced incorrectly. If your's just says $TERM_PROGRAM then it is wrong. I think it should be $?TERM_PROGRAM. The recommendations are to just comment out those 3 lines - they just attempt to set the name of the window to some weird thing that no one likes anyway.

You should be able to put .cshrc, .login and .logout files in your home directory and have only one line in each to source the examples (like it says in the examples/* file). Start there and build it up after you get that to work. You don't need to use the technique of putting stuff in ~/Library/init. To start off with don't use those (make sure you rename the init folder to init.bak or something else). Plus, you can just add stuff directly into your .cshrc anyway. I don't see any good reason to use that init thing.

And yes, you can use a .cshrc instead of a .tcshrc file and tcsh will read it, but only if there isn't a .tcshrc also. That way the settings will work regardless if you use tcsh or csh. You can put stuff in a .tcshrc file if you only want them when using tcsh and not csh. I think if you do that you have to manually source the .cshrc file in the .tcshrc file to get that stuff in tcsh.

I'm not sure about the $FOO versus ${FOO} thing. They both seem to work when used in my .tchsrc. I know that you have to use $(FOO) in makefiles though.

set is for setting tcsh/csh variables. I don't believe those are available outside of the shell environment, e.g. I don't think they are available to spawned processes.

setenv is for setting environment variables. These are available to spawned processes.

export is an sh thing.
(Last edited by JNI; Dec 25, 2002 at 07:48 AM. )
     
Fresh-Faced Recruit
Join Date: Dec 2002
Status: Offline
Reply With Quote
Dec 25, 2002, 05:41 PM
 
cheers mate, thanks for the tips. everything is working properly now!
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:05 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2