Subject: Re: shell-command and shell-command-on-region

From: Milt Epstein <[email-masked]>
Date: Mon, 30 Sep 1996 18:20:13 -0500 (CDT)

On 30 Sep 1996, Brent Benson wrote:

> Chris Kolb <[email-masked]> writes:
> > 
> > Good Morning,  I've been running emacs for years on Unix systems, and am
> > just switching to PC's, and I'm having problems with the shell-command and
> > shell-command-on-region.  Shell-mode operates as expected, and invokes my
> > prefered shell (currently MKS's Korn shell).  The shell-command and
> > shell-command on region return the following message: "/c: /c: not found".
> 
> You should use:
> 
>   (setq shell-command-switch "-c")
> 
> in your .emacs file.

I ran into this same problem (except I'm using tcsh), and this is the
same solution I came up with.  It took a little bit of poking around
to find out what was going on.  The problem is that the following line
appears in winnt.el (which is automatically loaded from loadup.el,
which I believe means it's effectively compiled in to the dumped
emacs):

   (setq shell-command-switch "/c")

This effectively makes the assumption that everyone using ntemacs is
using cmd.exe as their shell (or some command interpreter that uses
"/" style switches as opposed to "-" style ones) -- this assumption is
too strong, since lots of people are using UNIX-type shells like bash,
ksh, and tcsh.  Wouldn't it be better if instead of hard-coding this
setting, it was placed inside a conditional and/or a hook, so that it
could check which shell was being used before setting it?  (I'm not
sure what the conditional should check for or whether an appropriate
hook exists, although there appears to be a shell-mode-hook.)

Milt Epstein
Software Engineer
Central Data Corporation
[email-masked]
WWW: http://www.cd.com/
FTP: ftp.cd.com