all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "George D. Plymale" <georgedp@orbitalimpact.com>
To: npostavs@users.sourceforge.net
Cc: 26161@debbugs.gnu.org
Subject: bug#26161: 25.1; `eshell-exit-success-p' determines that Lisp commands are successful if they return non-nil
Date: Tue, 11 Apr 2017 15:48:05 -0400	[thread overview]
Message-ID: <446FF585-0B21-4774-8966-DCECB218C96B@orbitalimpact.com> (raw)
In-Reply-To: <7E4E5778-FFBF-4298-9DEF-0A60539999D5@orbitalimpact.com>

[-- Attachment #1: Type: text/plain, Size: 2518 bytes --]


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment; filename=bug_26161_fix.diff
Content-Description: Fix for bug#26161

diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el
index 583ba6ac42..86e7b83c28 100644
--- a/lisp/eshell/esh-cmd.el
+++ b/lisp/eshell/esh-cmd.el
@@ -575,14 +575,9 @@ eshell-rewrite-if-command
(defvar eshell-last-command-result)     ;Defined in esh-io.el.

(defun eshell-exit-success-p ()
-  "Return non-nil if the last command was \"successful\".
-For a bit of Lisp code, this means a return value of non-nil.
-For an external command, it means an exit code of 0."
-  (if (save-match-data
-	(string-match "#<\\(Lisp object\\|function .*\\)>"
-		      eshell-last-command-name))
-      eshell-last-command-result
-    (= eshell-last-command-status 0)))
+  "Return non-nil if the last command was successful.
+This means an exit code of 0."
+  (= eshell-last-command-status 0))

(defvar eshell--cmd)

@@ -1257,6 +1252,7 @@ eshell-exec-lisp
         (and result (funcall printer result))
         result)
     (error
+     (setq eshell-last-command-status 1)
      (let ((msg (error-message-string err)))
        (if (and (not form-p)
                 (string-match "^Wrong number of arguments" msg)

--=-=-=
Content-Type: text/plain

Okay, so I created a patch to fix this issue. Go easy on me since this
is my first patch to Emacs ;)

The changes are pretty simple:

- `eshell-exit-success-p' has been changed to only check if the last
  exit code was zero, rather than first checking whether the last command
  returned nil.
- `eshell-exec-lisp' has been changed so that it will set
  `eshell-last-command-status' to 1 if it catches an error.
- These changes together make it so that the `&&' operator in Eshell
  behaves more expectedly to someone who has used a bash-like shell and
  so that other things involving the success of Lisp commands in Eshell
  are more reliable.
  
Feel free to point out anything else that should be done here or any
errors on my part. I have tested these changes out and everything seems
okay. I can run the aforementioned commands that were problematic. Examples:

~ $ cd .. && pwd
/Users

/Users $ cd - && pwd
/Users/my_username

~ $ .. && pwd
/Users

/Users $ cd - && pwd
/Users/my_username

~ $ cat ~/.emacs && pwd
;; Emacs init file stuff
(foo bar)/Users/my_username

~ $ cat nowhere && pwd
cat: nowhere: No such file or directory

~ $ cat nowhere ; pwd
cat: nowhere: No such file or directory
/Users/my_username

~ $ 

--=-=-=--




[-- Attachment #2: Type: text/html, Size: 5598 bytes --]

  parent reply	other threads:[~2017-04-11 19:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-18 19:12 bug#26161: 25.1; `eshell-exit-success-p' determines that Lisp commands are successful if they return non-nil George D. Plymale
2017-03-31  3:52 ` npostavs
2017-04-01 23:46 ` George D. Plymale
2017-04-02  0:06   ` npostavs
2017-04-11 19:48 ` George D. Plymale [this message]
2017-04-13  1:18   ` npostavs
2017-04-20 19:47     ` George Plymale II
2017-04-21  3:10       ` npostavs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=446FF585-0B21-4774-8966-DCECB218C96B@orbitalimpact.com \
    --to=georgedp@orbitalimpact.com \
    --cc=26161@debbugs.gnu.org \
    --cc=npostavs@users.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.