Subject: bug#29156: 25.3; eshell/kill does not understand -<signal>

From: Noam Postavsky <[email-masked]>
Date: Sun, 05 Nov 2017 07:38:37 -0500

tags 29156 + confirmed
quit

Pierre Neidhardt <[email-masked]> writes:

> - emacs -Q
> - M-x eshell
> ~ $ kill -9 emacs
> kill: bad pid: -9

This bit converts the "-9" into an integer:

(defun eshell-lisp-command (object &optional args)
   ...
		  ;; if any of the arguments are flagged as numbers
		  ;; waiting for conversion, convert them now
		  (unless (get object 'eshell-no-numeric-conversions)
		    (while args
		      (let ((arg (car args)))
			(if (and (stringp arg)
				 (> (length arg) 0)
				 (not (text-property-not-all
				       0 (length arg) 'number t arg)))
			    (setcar args (string-to-number arg))))
		      (setq args (cdr args))))
  ...

Whereas this bit expects "-9" as a string:

(defun eshell/kill (&rest args)
  ...
      (when (stringp arg)
        (cond
         ((string-match "\\`-[[:digit:]]+\\'" arg)
          (setq signum (abs (string-to-number arg))))
         ((string-match "\\`-\\([[:upper:]]+\\|[[:lower:]]+\\)\\'" arg)
          (setq signum (abs (string-to-number arg)))))
  ...

Using "-SIGKILL" doesn't work either, because eshell/kill calls
`string-to-number' on it, giving 0.  Apparently nobody ever actually
used this feature before.