Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!decvax!harpo!seismo!hao!hplabs!sri-unix!mrose.uci-750a@rand-relay From: mrose.uci-750a%rand-relay@sri-unix.UUCP Newsgroups: net.unix-wizards Subject: Re: Should "su" change the USER environment variable? Message-ID: <12957@sri-arpa.UUCP> Date: Mon, 24-Oct-83 23:19:35 EDT Article-I.D.: sri-arpa.12957 Posted: Mon Oct 24 23:19:35 1983 Date-Received: Fri, 28-Oct-83 10:54:02 EDT Lines: 39 From: Marshall Rose Well, (it's my opinion that) $USER is a convenient method to determine who you want to say you logged in as. Under 4.1a, for example, if you use a /dev/ptyxx to give a process its own control-terminal, it doesn't have an entry in /etc/utmp. Hence, things like getlogin() may not work as expected. In cases like this, $USER is real useful as a pointer to who you logged in as. Granted, you can easily change it, so it's not a guaranteed method. It also seems to me that when something runs under cron, it doesn't have a $USER. This makes it real easy for a script (e.g., .cshrc) to tell when it's running under the restricted cron environment. For example, I have several maintenance logins that I and others use quite heavily. We each have our own preferred aliases, etc., etc., so we each would want to have a copy of our own .cshrc in place for these logins. Instead, we use this, which does the obvious things and we all live in pseudo-harmony. printenv USER >& /dev/null if ($status != 0) then set path=(/bin /usr/ucb /usr/bin /usr/uci .) goto crontab endif if (-r ~/.$USER) then source ~/.$USER else if (~$USER/.cshrc != ~/.cshrc) source ~$USER/.cshrc endif umask 0022 crontab: Granted, there are lots of ways of doing this, but it works well for our purposes. /mtr