]> code.delx.au - gnu-emacs/blobdiff - lisp/shell.el
merge trunk
[gnu-emacs] / lisp / shell.el
index fc8f3dfb940321cfc0a9febb27a0407ea14e4fc3..2047543f288c1eb40c246b13d1ea08e963c4e062 100644 (file)
@@ -1,6 +1,6 @@
 ;;; shell.el --- specialized comint.el for running the shell -*- lexical-binding: t -*-
 
-;; Copyright (C) 1988, 1993-1997, 2000-2012 Free Software Foundation, Inc.
+;; Copyright (C) 1988, 1993-1997, 2000-2013 Free Software Foundation, Inc.
 
 ;; Author: Olin Shivers <shivers@cs.cmu.edu>
 ;;     Simon Marshall <simon@gnu.org>
   "Directory support in shell mode."
   :group 'shell)
 
-(defgroup shell-faces nil
-  "Faces in shell buffers."
-  :group 'shell)
+;; Unused.
+;;; (defgroup shell-faces nil
+;;;   "Faces in shell buffers."
+;;;   :group 'shell)
 
 ;;;###autoload
 (defcustom shell-dumb-shell-regexp (purecopy "cmd\\(proxy\\)?\\.exe")
@@ -282,21 +283,9 @@ Value is a list of strings, which may be nil."
 ;; Note: There are no explicit references to the variable `explicit-bash-args'.
 ;; It is used implicitly by M-x shell when the interactive shell is `bash'.
 (defcustom explicit-bash-args
-  (let* ((prog (or (and (boundp 'explicit-shell-file-name) explicit-shell-file-name)
-                  (getenv "ESHELL") shell-file-name))
-        (name (file-name-nondirectory prog)))
-    ;; Tell bash not to use readline, except for bash 1.x which
-    ;; doesn't grok --noediting.  Bash 1.x has -nolineediting, but
-    ;; process-send-eof cannot terminate bash if we use it.
-    (if (and (not purify-flag)
-            (equal name "bash")
-            (file-executable-p prog)
-            (string-match "bad option"
-                          (shell-command-to-string
-                           (concat (shell-quote-argument prog)
-                                   " --noediting"))))
-       '("-i")
-      '("--noediting" "-i")))
+  ;; Tell bash not to use readline.  It's safe to assume --noediting now,
+  ;; as it was introduced in 1996 in Bash version 2.
+  '("--noediting" "-i")
   "Args passed to inferior shell by \\[shell], if the shell is bash.
 Value is a list of strings, which may be nil."
   :type '(repeat (string :tag "Argument"))
@@ -802,7 +791,7 @@ and `shell-pushd-dunique' control the behavior of the relevant command.
 Environment variables are expanded, see function `substitute-in-file-name'."
   (if shell-dirtrackp
       ;; We fail gracefully if we think the command will fail in the shell.
-      (condition-case nil
+      (with-demoted-errors "Couldn't cd: %s"
          (let ((start (progn (string-match
                               (concat "^" shell-command-separator-regexp)
                               str) ; skip whitespace
@@ -835,8 +824,7 @@ Environment variables are expanded, see function `substitute-in-file-name'."
              (setq start (progn (string-match shell-command-separator-regexp
                                               str end)
                                 ;; skip again
-                                (match-end 0)))))
-       (error "Couldn't cd"))))
+                                (match-end 0))))))))
 
 (defun shell-unquote-argument (string)
   "Remove all kinds of shell quoting from STRING."
@@ -918,7 +906,7 @@ Environment variables are expanded, see function `substitute-in-file-name'."
           (cond ((> num (length shell-dirstack))
                  (message "Directory stack not that deep."))
                 ((= num 0)
-                 (error (message "Couldn't cd")))
+                 (error "Couldn't cd"))
                 (shell-pushd-dextract
                  (let ((dir (nth (1- num) shell-dirstack)))
                    (shell-process-popd arg)
@@ -1025,12 +1013,11 @@ command again."
                         ds))
          (setq i (match-end 0)))
        (let ((ds (nreverse ds)))
-         (condition-case nil
-             (progn (shell-cd (car ds))
-                    (setq shell-dirstack (cdr ds)
-                          shell-last-dir (car shell-dirstack))
-                    (shell-dirstack-message))
-           (error (message "Couldn't cd"))))))
+         (with-demoted-errors "Couldn't cd: %s"
+           (shell-cd (car ds))
+           (setq shell-dirstack (cdr ds)
+                 shell-last-dir (car shell-dirstack))
+           (shell-dirstack-message)))))
     (if started-at-pmark (goto-char (marker-position pmark)))))
 
 ;; For your typing convenience:
@@ -1132,7 +1119,7 @@ Returns t if successful."
   (interactive)
   (let ((data (shell-command-completion)))
     (if data
-       (prog2 (unless (window-minibuffer-p (selected-window))
+       (prog2 (unless (window-minibuffer-p)
                 (message "Completing command name..."))
            (apply #'completion-in-region data)))))
 
@@ -1242,7 +1229,7 @@ Returns non-nil if successful."
   (interactive)
   (let ((data (shell-environment-variable-completion)))
     (if data
-       (prog2 (unless (window-minibuffer-p (selected-window))
+       (prog2 (unless (window-minibuffer-p)
                 (message "Completing variable name..."))
            (apply #'completion-in-region data)))))