unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#43055: 27.1; [PATCH] * lisp/term.el: Use correct exit status in suggested dir-tracking functions
@ 2020-08-26  3:58 Phil Sainty
  2020-08-26 10:03 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Phil Sainty @ 2020-08-26  3:58 UTC (permalink / raw)
  To: 43055

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

The shell function overrides suggested in term.el to facilitate
directory tracking cause those commands to return a success status
unconditionally:

cd()    { command cd    "$@"; printf '\033AnSiTc %s\n' "$PWD"; }
pushd() { command pushd "$@"; printf '\033AnSiTc %s\n' "$PWD"; }
popd()  { command popd  "$@"; printf '\033AnSiTc %s\n' "$PWD"; }

I.e. if the 'cd' fails, we are ignoring that and instead returning
the 'printf' exit status.

I believe these should be:

cd()    { command cd    "$@" && printf '\033AnSiTc %s\n' "$PWD"; }
pushd() { command pushd "$@" && printf '\033AnSiTc %s\n' "$PWD"; }
popd()  { command popd  "$@" && printf '\033AnSiTc %s\n' "$PWD"; }

If the command fails, no dir-tracking update should be needed in
Emacs (so it's fine not to do that part), and we will see the exit
status for the original command, so I think this is all that's
required.

Patch attached.


-Phil

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-term.el-Use-correct-exit-status-in-suggested-di.patch --]
[-- Type: text/x-diff; name=0001-lisp-term.el-Use-correct-exit-status-in-suggested-di.patch, Size: 1073 bytes --]

From d5e4a6fb53315621ed161986d9d01c3c2bb74357 Mon Sep 17 00:00:00 2001
From: Phil Sainty <psainty@orcon.net.nz>
Date: Wed, 26 Aug 2020 15:40:33 +1200
Subject: [PATCH] * lisp/term.el: Use correct exit status in suggested
 dir-tracking functions

---
 lisp/term.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lisp/term.el b/lisp/term.el
index 09dfeb61d1..401ee7d859 100644
--- a/lisp/term.el
+++ b/lisp/term.el
@@ -241,9 +241,9 @@
 ;;		printf '\033AnSiTu %s\n' "$USER"
 ;;		printf '\033AnSiTc %s\n' "$PWD"
 ;;
-;;		cd()    { command cd    "$@"; printf '\033AnSiTc %s\n' "$PWD"; }
-;;		pushd() { command pushd "$@"; printf '\033AnSiTc %s\n' "$PWD"; }
-;;		popd()  { command popd  "$@"; printf '\033AnSiTc %s\n' "$PWD"; }
+;;		cd()    { command cd    "$@" && printf '\033AnSiTc %s\n' "$PWD"; }
+;;		pushd() { command pushd "$@" && printf '\033AnSiTc %s\n' "$PWD"; }
+;;		popd()  { command popd  "$@" && printf '\033AnSiTc %s\n' "$PWD"; }
 ;;
 ;;		# Use custom dircolors in term buffers.
 ;;		# eval $(dircolors $HOME/.emacs_dircolors)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#43055: 27.1; [PATCH] * lisp/term.el: Use correct exit status in suggested dir-tracking functions
  2020-08-26  3:58 bug#43055: 27.1; [PATCH] * lisp/term.el: Use correct exit status in suggested dir-tracking functions Phil Sainty
@ 2020-08-26 10:03 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-26 10:03 UTC (permalink / raw)
  To: Phil Sainty; +Cc: 43055

Phil Sainty <psainty@orcon.net.nz> writes:

> If the command fails, no dir-tracking update should be needed in
> Emacs (so it's fine not to do that part), and we will see the exit
> status for the original command, so I think this is all that's
> required.

Makes sense to me.  I've now applied the patch to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-26 10:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-26  3:58 bug#43055: 27.1; [PATCH] * lisp/term.el: Use correct exit status in suggested dir-tracking functions Phil Sainty
2020-08-26 10:03 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).