[net.emacs] Bug in Shell handling in GNUemacs V16.60

howie@cucca.UUCP (Howie Kaye) (11/18/85)

There was a bug in gnuemacs, where it was not using the shell
specified in the user's ESHELL variable for shell-commands.  Emacs was
instead using a variable shell-file-name.  This variable is set to the
value of the shell's SHELL variable in init_callproc in callproc.c,
but the ESHELL variable was ignored.  The diffs for a fix to the file
"callproc.c" are given below.


296c296,297
<   sh = (char *) getenv ("SHELL");
---
>   sh = (char *) getenv ("ESHELL");
>   if (!sh) sh = (char *) getenv ("SHELL");
304c305,306
< Initialized from the SHELL environment variable.");
---
> Initialized from the ESHELL environment variable, or the SHELL\n\
> environment variable if ESHELL doesn't exist.");


Howie Kaye				Sy.Howie@CU20B.ARPA             
Columbia University 			HKAUS@cuvma (bitnet)          
System'sf Integration Group		{...}!seismo!columbia!cucca!howie
-- 
Howie Kaye				Sy.Howie@CU20B.ARPA             
Columbia University 			HKAUS@cuvma (bitnet)          
System's Integration Group		{?}!seismo!columbia!cucca!howie

earle@smeagol.UUCP (Greg_Earle) (12/05/85)

In article <155@cucca.UUCP>, howie@cucca.UUCP (Howie Kaye) writes:
> 
> There was a bug in gnuemacs, where it was not using the shell
> specified in the user's ESHELL variable for shell-commands.  Emacs was
> instead using a variable shell-file-name.  This variable is set to the
> value of the shell's SHELL variable in init_callproc in callproc.c,
> but the ESHELL variable was ignored.  The diffs for a fix to the file
> "callproc.c" are given below.
> 
> ... "fix" given here ...
>  
> Howie Kaye				Sy.Howie@CU20B.ARPA             
> Columbia University 			HKAUS@cuvma (bitnet)          
> System's Integration Group		{?}!seismo!columbia!cucca!howie

Please, people ... read your documentation and source code before posting
"fixes" that make people scramble for their "patch" and re-make all of
GNU Emacs!!

On page 154 of the Manual (28.1.1 Single Shell Commands) we have:
" M-! (shell-command) reads a line etc etc. ...
  M-| (shell-command-on-region) is like M-! etc etc. ...
  Both M-! and M-| use shell-file-name to specify the shell to use.  This
variable is initialized based on your SHELL environment variable when
Emacs is started."

It states NOTHING about referencing ESHELL.  Hopefully Howie merely confused
this command with that in the next section, 28.1.2 Interactive Inferior Shell
(Manual pages 154-155).  In it we find:
"The file name used to load the subshell is the value of the variable
explicit-shell-file-name, if that is non-nil.  Otherwise, the ESHELL
environment variable is used, or the SHELL environment variable, if there
is no ESHELL."

A check of the EXISTING code shows that there is *no* bug -

% sed -n '88,104p' shell.el
(defun shell ()
  "Run an inferior shell, with I/O through buffer *shell*.
If buffer exists but shell process is not running, make new shell.
Program used comes from variable explicit-shell-file-name,
 or (if that is nil) from the ESHELL environment variable,
 or else from SHELL if there is no ESHELL.
If a file ~/.emacs_SHELLNAME exists, it is given as initial input
 (Note that this may lose due to a timing error if the shell
  discards input when it starts up.)
The buffer is put in shell-mode, giving commands for sending input
and controlling the subjobs of the shell.  See shell-mode.
See also variable shell-prompt-pattern.

Note that many people's .cshrc files unconditionally clear the prompt.
If yours does, you will probably want to change it."
  (interactive)
  (let* ((prog (or explicit-shell-file-name (getenv "ESHELL") (getenv "SHELL")))

Note this last line.  This works as it says it should!

In callproc.c, init_callproc does:
% sed -n '287,299p' callproc.c
init_callproc ()
{
  char *sh;

  Vexec_path = nconc2 (decode_env_path ("PATH", ""),
		       decode_env_path ("%$&*#", PATH_EXEC));
  Vexec_directory = build_string (PATH_EXEC);
  Vexec_directory = concat2 (Vexec_directory, build_string ("/"));

  sh = (char *) getenv ("SHELL");
  Vshell_file_name = build_string (sh ? sh : "/bin/sh");
}

which does EXACTLY what 28.1.1 says it should do.

"If it works, don't fix it!"

-------------------------

	Greg Earle
	Jet Propulsion Laboratory
	...!sdcrdcf!smeagol!earle