Begin main content

Making Emacs shell work with Rational ClearCase

I was having a problem where the emacs shell was flakey when started from a shell within a clearcase view.

If the shell was csh (urgh), M-x shell would result in an error about a bad tty.

If the shell was bash, then all would seem fine, but I could not interrupt a subprocess (eg. with C-c C-c). I presume that emacs decided it was not the process owner, but I never delved into the C source.

My solution was to subclass the emacs shell to run bash directly with some funky environment munging.

Based on a post to the help-emacs-windows mailing list by Theodore Jump (read in archive), I cooked up the following proc:

(defun bash ()
  "Load Bourne Again Shell for interactive shell processing"
  (interactive)
  (require 'shell)
  (let ((binary-process-input t)        ; for 19.x
        (binary-process-ouput nil)      ; for 19.x
        (coding-system-for-write 'no-conversion) ; for 20.x
        (coding-system-for-read 'iso-latin-1-unix) ; for 20.x
        (explicit-bash-args '("-i"))
        (explicit-shell-file-name "")
        (original-shell (getenv "SHELL"))
        (ori-sfn shell-file-name)
        (w32-quite-process-args ?\")
        )
    ;; Wipe out PID in case emacs is called from
    ;; Cygwin32 built BASH (this causes problems)
    (setenv "PID" nil)
    (setenv "SHELL" "/bin/bash")
    (setq-default shell-file-name (getenv "SHELL")
                  explicit-shell-file-name shell-file-name)
    (message (format "invoking bash ... %s" shell-file-name) )
    (shell)
    (setq-default shell-file-name ori-sfn)
    (setenv "SHELL" original-shell)
    )
  )
So now instead of M-x shell I invoke M-x bash and all is good - interrupts, vobs, tab completion and all :)

There is, though, a slightly annoying echo of the commandline when you hit enter - I will investigate later.

12:10 AM, 23 Sep 2004 by Mark Aufflick Permalink

Add comment