0

I run emacs on windows. I use cygwin and I have cygwin versions of ruby and rdebug installed as well. When I invoke M-x comint-run ENTER rdebug ENTER, I noticed that it is attempting to run rdebug.bat via the Microsoft Command prompt, instead of using bash to run rdebug (without the .bat). I'd like comint-run to use bash to invoke any process that it is asked to start. Any ideas on how I can do this?

If you are interested in why I'm doing this, see here for the long story: Ideas for troubleshooting emacs error: "apply: Spawning child process: exec format error"

Minor progress

I did some digging around in the elisp code for comint-run and it looks like it finally calls into start-process - unfortunately, here I'm stuck since start-process is a function defined in C source code. And start-process, for some reason, seems to ignore the values of explicit-shell-file-name and shell-file-name.

Community
  • 1
  • 1
Rohith
  • 2,043
  • 1
  • 17
  • 42

4 Answers4

2

I have this in my .emacs

(setenv "SHELL" "C:/cygwin/bin/bash.exe")
(setq shell-file-name "C:/cygwin/bin/bash.exe")
(add-hook 'comint-output-filter-functions 'shell-strip-ctrl-m nil t)

I'm no elisp hacker and I copied and pasted this code from somewhere a long time ago. I don't know if it will help you. But at least it runs bash when I do "M-x shell".

Jörgen Lundberg
  • 1,799
  • 3
  • 22
  • 31
2

Emacs start-process does not use any shell at all as far as I can tell — it launches the program you specify directly without intermediate processes. Naturally, if you specify a batch file (.BAT), it will be executed using the Microsoft Command Shell.

If you have multiple files named similarly (one ending in .BAT, and another not), I suggest you make sure the correct one is executed by specifying the full path. It is not Emacs, but Windows that is launching the Command Shell to interpret the batch file Emacs asked it to execute.

Markus Miller
  • 3,695
  • 2
  • 29
  • 33
1

Jörgen Lundberg's answer will surely work, however Emacs first looks at the value of the variable explicit-shell-file-name to determine which shell to run for an interactive inferior shell (check the link for documentation). So, the sure-fire answer would be to set:

(setq explicit-shell-file-name "C:/cygwin/bin/bash.exe")
Community
  • 1
  • 1
Trey Jackson
  • 73,529
  • 11
  • 197
  • 229
  • Doesn't work - I already have explicit-shell-file-name and shell-file-name set to bash (and indeed M-x shell invokes bash correctly). But comint-run seems to ignore these. – Rohith Feb 16 '10 at 00:28
1

In spite of a lot of elisp debugging, I couldn't figure out a way to customise the start-process to use cygwin bash. Now that I look back on this, it sort of makes sense to me: assuming that emacs uses start-process to start different processes that it needs internally as well, start-process would always need to invoke a shell which depends on the underlying operating system rather than any user customisations.

Rohith
  • 2,043
  • 1
  • 17
  • 42