From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eric Skoglund Newsgroups: gmane.emacs.bugs Subject: bug#29156: 25.3; eshell/kill does not understand -, [PATCH] Make eshell/kill handle - and - Date: Sat, 17 Mar 2018 18:43:29 +0100 Message-ID: <87zi3661j2.fsf@pagefault.se> References: <87vaiprmg5.fsf@gmail.com> <87o9jnv9et.fsf@gmail.com> <87lgerv8tq.fsf@gmail.com> <83lgeroz7r.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1521310032 25689 195.159.176.226 (17 Mar 2018 18:07:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 17 Mar 2018 18:07:12 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 29156@debbugs.gnu.org, Noam Postavsky , ambrevar@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Mar 17 19:07:08 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1exGEV-0006Xk-K8 for geb-bug-gnu-emacs@m.gmane.org; Sat, 17 Mar 2018 19:07:07 +0100 Original-Received: from localhost ([::1]:34512 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1exGGW-0008D2-IE for geb-bug-gnu-emacs@m.gmane.org; Sat, 17 Mar 2018 14:09:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58593) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1exGGQ-0008Ai-6f for bug-gnu-emacs@gnu.org; Sat, 17 Mar 2018 14:09:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1exGGM-00039E-6O for bug-gnu-emacs@gnu.org; Sat, 17 Mar 2018 14:09:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:58976) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1exGGM-00038h-0s for bug-gnu-emacs@gnu.org; Sat, 17 Mar 2018 14:09:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1exGGL-0005Pf-P4 for bug-gnu-emacs@gnu.org; Sat, 17 Mar 2018 14:09:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eric Skoglund Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 17 Mar 2018 18:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29156 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed easy Original-Received: via spool by 29156-submit@debbugs.gnu.org id=B29156.152131008620738 (code B ref 29156); Sat, 17 Mar 2018 18:09:01 +0000 Original-Received: (at 29156) by debbugs.gnu.org; 17 Mar 2018 18:08:06 +0000 Original-Received: from localhost ([127.0.0.1]:38640 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1exGFS-0005OQ-I5 for submit@debbugs.gnu.org; Sat, 17 Mar 2018 14:08:06 -0400 Original-Received: from pagefault.se ([31.7.186.167]:49132) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1exFrg-0004ig-3B for 29156@debbugs.gnu.org; Sat, 17 Mar 2018 13:43:32 -0400 Original-Received: by pagefault.se (Postfix, from userid 5555) id E12AA9220107; Sat, 17 Mar 2018 17:43:30 +0000 (UTC) Original-Received: from pagefault.se (c-460be255.07-19-73746f67.cust.bredbandsbolaget.se [85.226.11.70]) by pagefault.se (Postfix) with ESMTPSA id 6A2F89220101; Sat, 17 Mar 2018 17:43:30 +0000 (UTC) In-Reply-To: <83lgeroz7r.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 17 Mar 2018 10:58:32 +0200") X-Mailman-Approved-At: Sat, 17 Mar 2018 14:08:05 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:144375 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Noam Postavsky >> Date: Fri, 16 Mar 2018 20:34:25 -0400 >> Cc: Eric Skoglund , Pierre Neidhardt >> >> > ((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. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Make-eshell-kill-handle-signal-and-SIGNALNAME.patch Content-Description: Patch v2 >From 54bca6f5420d80abeaf9c1da5b73d50112eaab71 Mon Sep 17 00:00:00 2001 From: Eric Skoglund Date: Fri, 16 Mar 2018 14:49:56 +0100 Subject: [PATCH] Make eshell/kill handle - and - * 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 [-] | ... -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 --=-=-= Content-Type: text/plain // Eric --=-=-=--