unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eric Skoglund <eric@pagefault.se>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 29156@debbugs.gnu.org, Noam Postavsky <npostavs@gmail.com>,
	ambrevar@gmail.com
Subject: bug#29156: 25.3; eshell/kill does not understand -<signal>, [PATCH] Make eshell/kill handle -<signal> and -<SIGNALNAME>
Date: Sat, 17 Mar 2018 18:43:29 +0100	[thread overview]
Message-ID: <87zi3661j2.fsf@pagefault.se> (raw)
In-Reply-To: <83lgeroz7r.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 17 Mar 2018 10:58:32 +0200")

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

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Noam Postavsky <npostavs@gmail.com>
>> Date: Fri, 16 Mar 2018 20:34:25 -0400
>> Cc: Eric Skoglund <eric@pagefault.se>, Pierre Neidhardt <ambrevar@gmail.com>
>> 
>> >           ((string-match "\\`-\\([[:upper:]]+\\|[[:lower:]]+\\)\\'" arg)
>> > -          (setq signum (abs (string-to-number arg)))))
>> > +          (setq signum (make-symbol (substring arg 1 (length arg))))))
>> 
>> Not sure this `make-symbol' call, should it rather be `intern'?
>
> Yes, I think intern is better here.
>
>> (Maybe we should update signal-process take a string as well a
>> symbol.)
>
> Possibly.
>
> Btw, the doc string of eshell/kill should be updated to reflect the
> fact we now support symbolic names of Unix signals.  Also, NEWS and
> the Eshell manual should be updated.

Here is an updated patch which hopefully fixes all the issues with the
previous.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Patch v2 --]
[-- Type: text/x-patch, Size: 2966 bytes --]

From 54bca6f5420d80abeaf9c1da5b73d50112eaab71 Mon Sep 17 00:00:00 2001
From: Eric Skoglund <eric@pagefault.se>
Date: Fri, 16 Mar 2018 14:49:56 +0100
Subject: [PATCH] Make eshell/kill handle -<signal> and -<SIGNALNAME>

     * lisp/eshell/esh-proc.el (eshell/kill):
     Handle the argument parsing and numeric conversion in function
     in order to parse -signal and -SIGNALNAME correctly.
---
 doc/misc/eshell.texi    | 2 +-
 etc/NEWS                | 5 +++++
 lisp/eshell/esh-proc.el | 9 ++++++---
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/doc/misc/eshell.texi b/doc/misc/eshell.texi
index 80077e5ccd..bda6159488 100644
--- a/doc/misc/eshell.texi
+++ b/doc/misc/eshell.texi
@@ -330,7 +330,7 @@ Built-ins
 @item kill
 @cmindex kill
 Kill processes.  Takes a PID or a process object and an optional
-signal specifier.
+signal specifier which can either be a number or a signal name.
 
 @item listify
 @cmindex listify
diff --git a/etc/NEWS b/etc/NEWS
index b6c4157384..bfd9a33040 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -273,6 +273,11 @@ To restore the old behavior, use
 *** The function 'shell-uniquify-list' has been renamed from
 'eshell-uniqify-list'.
 
+*** The function eshell/kill is now able to handle signal switches.
+Previously eshell/kill would fail if provided a kill signal to send to the
+process. It now handles both numeric signals and the string version of
+the signals.
+
 ** Pcomplete
 *** The function 'pcomplete-uniquify-list' has been renamed from
 'pcomplete-uniqify-list'.
diff --git a/lisp/eshell/esh-proc.el b/lisp/eshell/esh-proc.el
index b3bd7a7245..1fe4b324a6 100644
--- a/lisp/eshell/esh-proc.el
+++ b/lisp/eshell/esh-proc.el
@@ -167,7 +167,8 @@ eshell/jobs
 (defun eshell/kill (&rest args)
   "Kill processes.
 Usage: kill [-<signal>] <pid>|<process> ...
-Accepts PIDs and process objects."
+Accepts PIDs and process objects.  Optionally accept signals
+and signal names."
   ;; If the first argument starts with a dash, treat it as the signal
   ;; specifier.
   (let ((signum 'SIGINT))
@@ -178,12 +179,12 @@ eshell/kill
          ((string-match "\\`-[[:digit:]]+\\'" arg)
           (setq signum (abs (string-to-number arg))))
          ((string-match "\\`-\\([[:upper:]]+\\|[[:lower:]]+\\)\\'" arg)
-          (setq signum (abs (string-to-number arg)))))
+          (setq signum (intern (substring arg 1 (length arg))))))
         (setq args (cdr args))))
     (while args
       (let ((arg (if (eshell-processp (car args))
                      (process-id (car args))
-                   (car args))))
+                   (string-to-number (car args)))))
         (when arg
           (cond
            ((null arg)
@@ -198,6 +199,8 @@ eshell/kill
       (setq args (cdr args))))
   nil)
 
+(put 'eshell/kill 'eshell-no-numeric-conversions t)
+
 (defun eshell-read-process-name (prompt)
   "Read the name of a process from the minibuffer, using completion.
 The prompt will be set to PROMPT."
-- 
2.13.6


[-- Attachment #3: Type: text/plain, Size: 10 bytes --]



// Eric

  reply	other threads:[~2018-03-17 17:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-05 11:31 bug#29156: 25.3; eshell/kill does not understand -<signal> Pierre Neidhardt
2017-11-05 12:38 ` Noam Postavsky
2018-03-17  0:21 ` bug#29156: 25.3; eshell/kill does not understand -<signal>, [PATCH] Make eshell/kill handle -<signal> and -<SIGNALNAME> Noam Postavsky
2018-03-17  0:34   ` Noam Postavsky
2018-03-17  8:58     ` Eli Zaretskii
2018-03-17 17:43       ` Eric Skoglund [this message]
2018-03-17 19:33         ` Eli Zaretskii
     [not found]           ` <87muz65rh9.fsf@pagefault.se>
2018-03-23  1:05             ` Noam Postavsky
2018-03-23  6:03               ` Eric Skoglund
2018-03-25 15:34                 ` Noam Postavsky
2018-03-17 14:43 ` Noam Postavsky
2018-03-17 14:54   ` Noam Postavsky

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87zi3661j2.fsf@pagefault.se \
    --to=eric@pagefault.se \
    --cc=29156@debbugs.gnu.org \
    --cc=ambrevar@gmail.com \
    --cc=eliz@gnu.org \
    --cc=npostavs@gmail.com \
    /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 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).