[comp.windows.x] Why does xterm use $SHELL if available and not /etc/passwd

jludwig@pinocchio.encore.com (Jim Ludwig) (12/06/90)

xterm (X11R4 core dist) uses the SHELL environment variable to
determine which shell to run. It falls back on the password entry
shell if there is no SHELL environment variable set.

I'm curious as to the logic behind this. There's no mention of this
behavior in the man page.

The reason I'm asking, is that we have a make on our system which uses
SHELL to determine which shell to use. Since most Makefiles like to
use /bin/sh, you need to have SHELL set to /bin/sh. 

Any feelings on whether xterm should or shouldn't use the SHELL
variable over the /etc/passwd entry?

Jim Ludwig
Encore Computer Corp
jludwig@encore.com

meissner@osf.org (Michael Meissner) (12/07/90)

In article <13442@encore.Encore.COM> jludwig@pinocchio.encore.com (Jim
Ludwig) writes:

| xterm (X11R4 core dist) uses the SHELL environment variable to
| determine which shell to run. It falls back on the password entry
| shell if there is no SHELL environment variable set.
| 
| I'm curious as to the logic behind this. There's no mention of this
| behavior in the man page.
| 
| The reason I'm asking, is that we have a make on our system which uses
| SHELL to determine which shell to use. Since most Makefiles like to
| use /bin/sh, you need to have SHELL set to /bin/sh. 

Fix your Makefile's, don't break xterm.  Change the MAKEFILE to have a
line of the form:

	SHELL = /bin/sh

| Any feelings on whether xterm should or shouldn't use the SHELL
| variable over the /etc/passwd entry?

It definately should do the current behavior.  For example, I don't
use the standard shells (/bin/sh, /bin/csh) as my shell, I use bash.
I have 3 or 4 different platforms I log into, with bash in the
appropriate machine directory.  For example:

	~/bin.mips/bash
	~/bin.mmax/bash
	~/bin.vax/bash
	~/bin.at386/bash

On most systems (except for my workstation where I can edit
/etc/passwd), my default shell is /bin/sh or /bin/csh, and the
appropriate .profile/.login figures out that it's not running bash,
and what machine it's on, and exec's the appropriate bash, after
setting the SHELL variable.  I want any further xterms to use this
shell variables without adding any extra switches and such.
--
Michael Meissner	email: meissner@osf.org		phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142

Considering the flames and intolerance, shouldn't USENET be spelled ABUSENET?

ea08+@andrew.cmu.edu (Eric A. Anderson) (12/08/90)

Yes, I like the fact that it uses $SHELL or some environment variable.
This allows me to run a different shell in my xterms without much
problem, as I would be pretty unable to change the entry in
/etc/passwd
          -Eric
*********************************************************
"My life is full of additional complications spinning around until
 it makes my head snap off."
           -Unc. Known.
"You are very smart, now shut up."
           -In "The Princess Bride"
*********************************************************

mouse@LARRY.MCRCIM.MCGILL.EDU (12/10/90)

> Subject: Why does xterm use $SHELL if available and not /etc/passwd

In a sentence, because that's the right thing to do.

> xterm (X11R4 core dist) uses the SHELL environment variable to
> determine which shell to run.  It falls back on the password entry
> shell if there is no SHELL environment variable set.

(Whose passwd entry, by the way?  In my experience, xterm has been very
bad about confusing multiple users with the same UID.  I believe it
simply does getpwuid(getuid()); it could do much better than this.)

> I'm curious as to the logic behind this.

Probably because most other programs that run shells for the user to
interact with do the same thing.

> There's no mention of this behavior in the man page.

True as far as I can tell, and should probably be fixed.

> The reason I'm asking, is that we have a make on our system which
> uses SHELL to determine which shell to use.

Gack.

> Since most Makefiles like to use /bin/sh, you need to have SHELL set
> to /bin/sh. 

I'd prefer to write a small wrapper for make to fix it, rather than
setting SHELL to /bin/sh and breaking everything else.  Something like

% cat ~/bin/make
#! /bin/sh
SHELL=/bin/sh; export SHELL
case $# in
	0)	exec /bin/make ;;
	*)	exec /bin/make "$@" ;;
esac
%

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu

tony@oha.UUCP (Tony Olekshy) (12/11/90)

Interactive programs should use $SHELL, if available, to decide where to
pass shell commands *entered*by*the*user*.  That's what it's there for.

Some makefiles get confused if $SHELL isn't /bin/sh, which is a bug in make,
but you can use SHELL=/bin/sh in the Makefile as a simple workaround.

The Makefile usage of SHELL should not interfere with the interactive
program's use of SHELL, unless the Makefile passes it to the compiler with
-DSHELL= *and* the program uses this value, which it clearly shouldn't.

After all, the whole purpose of environment variables is to separate run-time
configuration information from the compile-time state of the environment.

--
Yours etc., Tony Olekshy.       Internet: tony%oha@CS.UAlberta.CA
				  BITNET: tony%oha.uucp@UALTAMTS.BITNET
				    uucp: alberta!oha!tony
Blowing is not playing the flute, you must make use of your fingers.--Goethe