[comp.emacs] emacs as a login shell

worley@compass.UUCP (Dale Worley) (11/29/88)

Is there anyone out there who uses Emacs as his login shell?

It used to be that the only thing that Emacs didn't allow you to do
was set up the environment for subprocesses, but with the advent of
process-environment, that's taken care of...

Dale

israel@BRILLIG.UMD.EDU (Bruce Israel) (11/30/88)

   From: think!compass!worley@eddie.mit.edu (Dale Worley)

   Is there anyone out there who uses Emacs as his login shell?

I wouldn't.  What if you want to login from a dialup or something?  With a
regular shell, you can set the  term type afterwards, but if emacs is your
login shell, then it'll come back with something like: 

    emacs: Terminal type "su" is not powerful enough to run Emacs.
    It lacks the ability to position the cursor.
    If that is not the actual type of terminal you have,
    use the C-shell command `setenv TERM ...' to specify the correct type.
    It may be necessary to do `unsetenv TERMCAP' as well.

and just exit.  What I would do is put something at the end of my .login
which says something like:

if ("$term" != "su" && "$term" != "sd" && "$term" != "network") then
	exec emacs
endif

I do a similar thing when using a window system (suntools, X) on a sun.
It checks to make sure that I'm on the console of a sun before replacing my
login shell with the relacement program.

Bruce

Mly@AI.AI.MIT.EDU (Richard Mlynarik) (11/30/88)

    Date: Tue, 29 Nov 88 10:13:34 EST
    From: think!compass!worley@eddie.mit.edu (Dale Worley)

    Is there anyone out there who uses Emacs as his login shell?

I have at various times.

    It used to be that the only thing that Emacs didn't allow you to do
    was set up the environment for subprocesses, but with the advent of
    process-environment, that's taken care of...

process-environment is misdesigned and incapable of doing what is
necessary.  (The `etc/env' program which comes with Emacs does what
process-environment thinks it is doing, but better...)

The only other thing of which I can think offhand which Emacs needs for
login-shell usage is a way to set the unix `umask'.

The `getenv' and `setenv' functions which Emacs provides
when compiled with the MAINTAIN_ENVIRONMENT option do provide the needed
funcitonality -- in particular, they can set environment variables which
are `seen' by Emacs (for example, in "$foo" filename expansion) and can
unset environment variables.

The real problem is that the unix login program (getty, or whatever it
is) generally doesn't pass an environment containining a TERM or TERMCAP
terminal-type specification.  Because Emacs punts and exits if it
doesn't know one's terminal-type, one may sometimes have a hard time
logging-in...

There are a couple of ways around this:
* Use some connection to the unix machine (like X, or SUPDUP) which
ensures that DISPLAY/TERMCAP are set up correctly.

* Try using something like the little program written by
Gumby@ai.ai.mit.edu which I forward to you.   This program hasn't been
used in a couple of years, was written as a quick hack, and all that.
If somebody wants to fix it up, then that would be great...  (It could
be built into emacs that if it sees that it was invoked with a name
whose first character was a `-' (isn't unix wonderful?) and it doesn't
know its terminal-type, then it should run some code like the below
rather than exiting and thus logging-out the user.)
The basic idea of the program is to read a terminal-type from the
keyboard using unix stream i/o (in the case in which TERM/TERMCAP haven't
been set up) and then `exec' Emacs.