unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#48072: 28.0.50: dired-read-shell-command: handle empty input properly [PATCH]
@ 2021-04-27 19:02 Boruch Baum
  2021-04-27 19:19 ` Eli Zaretskii
  2021-04-28 11:03 ` Michael Albinus
  0 siblings, 2 replies; 22+ messages in thread
From: Boruch Baum @ 2021-04-27 19:02 UTC (permalink / raw)
  To: 48072

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

Function dired-read-shell-command was accepting an empty input. This is
a bug because it then passes the empty input as a legitimate command
which is silently processed (in error) by dired, eventually to return a
completion message.

The attached patch fixes that, and also validates the entered command as
a valid shell executable.

--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0

[-- Attachment #2: dired-aux-read-shell-command.patch --]
[-- Type: text/x-diff, Size: 1530 bytes --]

diff --git a/dired-aux.el b/dired-aux.el
index 1c10990..7f5775c 100644
--- a/dired-aux.el
+++ b/dired-aux.el
@@ -674,15 +674,22 @@ This normally reads using `read-shell-command', but if the
 offer a smarter default choice of shell command."
   (minibuffer-with-setup-hook
       (lambda ()
-	(setq-local dired-aux-files files)
-	(setq-local minibuffer-default-add-function
-		    #'minibuffer-default-add-dired-shell-commands))
+        (setq-local dired-aux-files files)
+        (setq-local minibuffer-default-add-function
+                    #'minibuffer-default-add-dired-shell-commands))
     (setq prompt (format prompt (dired-mark-prompt arg files)))
-    (if (functionp 'dired-guess-shell-command)
-	(dired-mark-pop-up nil 'shell files
-			   'dired-guess-shell-command prompt files)
-      (dired-mark-pop-up nil 'shell files
-			 'read-shell-command prompt nil nil))))
+    (let (command)
+      (setq command
+        (if (functionp 'dired-guess-shell-command)
+          (dired-mark-pop-up nil 'shell files
+                             'dired-guess-shell-command prompt files)
+         (dired-mark-pop-up nil 'shell files
+                            'read-shell-command prompt nil nil)))
+      (when (string-empty-p command)
+        (user-error "No command entered. Nothing to do!"))
+      (unless (executable-find command)
+        (user-error "Not a valid command!"))
+      command)))

 ;;;###autoload
 (defun dired-do-async-shell-command (command &optional arg file-list)

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

end of thread, other threads:[~2021-04-28 17:10 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-27 19:02 bug#48072: 28.0.50: dired-read-shell-command: handle empty input properly [PATCH] Boruch Baum
2021-04-27 19:19 ` Eli Zaretskii
2021-04-27 19:32   ` Boruch Baum
2021-04-28  2:22     ` Eli Zaretskii
2021-04-28  3:00       ` Boruch Baum
2021-04-28  6:19         ` Kévin Le Gouguec
2021-04-28  9:33           ` Boruch Baum
2021-04-28  9:50           ` Boruch Baum
2021-04-28 11:58             ` Eli Zaretskii
2021-04-28 12:49               ` Boruch Baum
2021-04-28 13:03                 ` Eli Zaretskii
2021-04-28 15:01                   ` Boruch Baum
2021-04-28 15:13                     ` Eli Zaretskii
2021-04-28 15:21                       ` Boruch Baum
2021-04-28 15:52                         ` Eli Zaretskii
2021-04-28 17:10                           ` Michael Albinus
2021-04-28 15:16                   ` Boruch Baum
2021-04-28 11:47           ` Eli Zaretskii
2021-04-28 11:03 ` Michael Albinus
2021-04-28 12:00   ` Boruch Baum
2021-04-28 12:13     ` Michael Albinus
2021-04-28 12:46       ` Boruch Baum

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).