unix system enhancements

Karl Kleinpaste karl at cbrma.UUCP
Tue Sep 30 07:04:26 AEST 1986


guy at sun.uucp (Guy Harris) writes:
>> 	1.  Modify CSH so that it checks for the existence of a system wide
>> 	.cshrc and .login...
>
>Yes, several people have done this to the C shell...
>
>The trouble is that several people have done this, all giving the file
>a different name.  I think Plexus called it "/etc/cshlogin"; at CCI, I
>called it "/etc/login" (this won't work in System III, where the "login"
>program was moved to "/etc", but System V moved it back to "/bin"); you
>could also call it "/etc/.login", but that means "ls /etc" won't show it
>unless "ls" is showing "." files.  Karl Kleinpaste at Bell Labs Columbus
>called it "/etc/csh.login", as his also had to run on System III.
>
>One S3/S5 Bourne shell feature used by "/etc/profile" is that in an
>interactive shell, "$0" refers to the argv[0] of the shell that is running,
>so that it can tell whether it was invoked as "-sh", "-rsh", "-su", or
>other.  (The S5/S5 "login" doesn't do things like checking for mail,
>printing the message of the day, etc.; it leaves that up to "/etc/profile",
>or whatever your other login shells do.)  In Karl's C shell, "$0" was the
>argv[0] of the shell for interactive shells.  In order not to break existing
>scripts, "$?0" was true only for scripts, not for interactive shells.
>
>You out there, Karl?  What ever happened with that version of the C shell?

Yes, that csh is alive and well and runnning on a mess of SysIII/V
machines around Columbus, including but not necessarily limited to
cbrm[a-e], cbux[a-d], a small army of network-invisible 3B2s, 3B15s,
and 3B20s, and I don't know where all else.  A strange machine called
cbsnsz, methinks.  The SysV version has these hacks and a number of
others, including job control emulation which I mentioned here once
before.  The 4BSD version with similar hacks runs on a number of local
VAXen and Suns.

It correctly identifies $0 no matter how it is invoked, but does in
fact return True for $?0 only if invoked in a script - as Guy said,
that keeps scripts from breaking, though the usage of $?0 in scripts
is relatively rare.  The modification for using a global
.login-equivalent file is really, really trivial, done just before the
user's own .cshrc and .login.  At the point in main() (file sh.c),
where there is a comment, "Set an exit here in case of an interrupt,"
there's an "if" for whether or not .cshrc and .login should be
source'd.  The relevant code in my sources inside the if then looks
like

#ifdef CSHLOGIN
		if (loginsh)
			srccat ("", CSHLOGIN);
#endif CSHLOGIN

and then #define CSHLOGIN somewhere appropriate.  As Guy pointed out,
picking a filename for it is a pain because no two people will do it
the same, but I picked /etc/csh.login as a reasonable compromise.

I was going to distribute diffs of my mods to 4.2BSD csh a while back
but got stalled for silly administrivia reasons having to do with my
employer (ahem), but perhaps I'll go off and do it anyway - it's not
that big a deal overall.
-- 
Karl Kleinpaste



More information about the Comp.unix.wizards mailing list