unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Tino Calancha <f92capac@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Tino Calancha <f92capac@gmail.com>, 23206@debbugs.gnu.org
Subject: bug#23206: 25.0.92; dired-shell-stuff-it: wait until all parallel jobs finish
Date: Wed, 6 Apr 2016 00:58:30 +0900 (JST)	[thread overview]
Message-ID: <alpine.LRH.2.20.1604060052450.10077@calancha-ilc.kek.jp> (raw)
In-Reply-To: <83vb3wm791.fsf@gnu.org>

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


>These are unrelated changes, so please don't mix them with the changes
>that really fix the problem at hand.
I am sorry tha's my fault.  I should always do atomic changes.

>It is up to the user to type a correct command, and Emacs
>shouldn't try second-guessing those commands.  So let's only remove a
>single instance of these characters at the end, as the original code
>did.
I was 'baby sitting' the user (and my self). Yeah, too much care, 
Emacs users can protect themselves very well ;-)

Attached atomic commits without the extra care.

[-- Attachment #2: Type: text/plain, Size: 2895 bytes --]

From bd476a1f43be47fe79db76e7fea36c750549f72b Mon Sep 17 00:00:00 2001
From: Tino Calancha <f92capac@gmail.com>
Date: Wed, 6 Apr 2016 00:36:17 +0900
Subject: [PATCH 1/2] Wait until all parallel shell commands finish

* lisp/dired-aux.el (dired-shell-stuff-it):
Force POSIX shells to wait until all background jobs finish.
(Bug#23206).
---
 lisp/dired-aux.el | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index d29abf3..cc6f168 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -729,6 +729,7 @@ dired-shell-stuff-it
 	 (command (if sequentially
 		      (substring command 0 (match-beginning 0))
 		    command))
+         (parallel-in-background (and in-background (not sequentially)))
 	 (stuff-it
 	  (if (or (string-match-p dired-star-subst-regexp command)
 		  (string-match-p dired-quark-subst-regexp command))
@@ -740,15 +741,27 @@ dired-shell-stuff-it
 		  retval))
 	    (lambda (x) (concat command dired-mark-separator x)))))
     (concat
-     (if on-each
-	 (mapconcat stuff-it (mapcar 'shell-quote-argument file-list)
-		    (if (and in-background (not sequentially)) "&" ";"))
-       (let ((files (mapconcat 'shell-quote-argument
-			       file-list dired-mark-separator)))
-	 (if (> (length file-list) 1)
-	     (setq files (concat dired-mark-prefix files dired-mark-postfix)))
-	 (funcall stuff-it files)))
-     (if in-background "&" ""))))
+     (cond (on-each
+            (format "%s%s"
+                    (mapconcat stuff-it (mapcar 'shell-quote-argument file-list)
+                               (or (and parallel-in-background "&") ";"))
+                    ;; POSIX shells running a list of commands in the background
+                    ;; (LIST = cmd_1 & [cmd_2 & ... cmd_i & ... cmd_N &])
+                    ;; return once cmd_N ends, i.e., the shell does not
+                    ;; wait for cmd_i to finish before executing cmd_i+1.
+                    ;; That means, running (shell-command LIST) may not show
+                    ;; the output of all the commands (Bug#23206).
+                    ;; Add 'wait' to force those POSIX shells to wait until
+                    ;; all commands finish.
+                    (or (and parallel-in-background (not (memq system-type '(ms-dos windows-nt))) "&wait")
+                        "")))
+           (t
+            (let ((files (mapconcat 'shell-quote-argument
+                                    file-list dired-mark-separator)))
+              (when (cdr file-list)
+                (setq files (concat dired-mark-prefix files dired-mark-postfix)))
+              (funcall stuff-it files))))
+     (or (and in-background "&") ""))))
 
 ;; This is an extra function so that it can be redefined by ange-ftp.
 ;;;###autoload
-- 
2.8.0.rc3


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

From f0ed483aa3e8bf8345c807a6c0d944f177347c53 Mon Sep 17 00:00:00 2001
From: Tino Calancha <f92capac@gmail.com>
Date: Wed, 6 Apr 2016 00:46:02 +0900
Subject: [PATCH 2/2] dired-shell-stuff-it: Consistent indentation

* lisp/dired-aux.el (dired-shell-stuff-it):
Use spaces for indent this function.
---
 lisp/dired-aux.el | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index cc6f168..993b453 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -722,24 +722,24 @@ dired-shell-stuff-it
 ;; (coming from interactive P and currently ignored) to decide what to do.
 ;; Smart would be a way to access basename or extension of file names.
   (let* ((in-background (string-match "[ \t]*&[ \t]*\\'" command))
-	 (command (if in-background
-		      (substring command 0 (match-beginning 0))
-		    command))
-	 (sequentially (string-match "[ \t]*;[ \t]*\\'" command))
-	 (command (if sequentially
-		      (substring command 0 (match-beginning 0))
-		    command))
+         (command (if in-background
+                      (substring command 0 (match-beginning 0))
+                    command))
+         (sequentially (string-match "[ \t]*;[ \t]*\\'" command))
+         (command (if sequentially
+                      (substring command 0 (match-beginning 0))
+                    command))
          (parallel-in-background (and in-background (not sequentially)))
-	 (stuff-it
-	  (if (or (string-match-p dired-star-subst-regexp command)
-		  (string-match-p dired-quark-subst-regexp command))
-	      (lambda (x)
-		(let ((retval command))
-		  (while (string-match
-			  "\\(^\\|[ \t]\\)\\([*?]\\)\\([ \t]\\|$\\)" retval)
-		    (setq retval (replace-match x t t retval 2)))
-		  retval))
-	    (lambda (x) (concat command dired-mark-separator x)))))
+         (stuff-it
+          (if (or (string-match-p dired-star-subst-regexp command)
+                  (string-match-p dired-quark-subst-regexp command))
+              (lambda (x)
+                (let ((retval command))
+                  (while (string-match
+                          "\\(^\\|[ \t]\\)\\([*?]\\)\\([ \t]\\|$\\)" retval)
+                    (setq retval (replace-match x t t retval 2)))
+                  retval))
+            (lambda (x) (concat command dired-mark-separator x)))))
     (concat
      (cond (on-each
             (format "%s%s"
-- 
2.8.0.rc3


  reply	other threads:[~2016-04-05 15:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-03 13:02 bug#23206: 25.0.92; dired-shell-stuff-it: wait until all parallel jobs finish Tino Calancha
2016-04-03 15:03 ` Eli Zaretskii
2016-04-03 16:38   ` Tino Calancha
2016-04-04  6:20     ` Tino Calancha
2016-04-04 17:25     ` Eli Zaretskii
2016-04-05  5:24       ` Tino Calancha
2016-04-05 14:59         ` Eli Zaretskii
2016-04-05 15:58           ` Tino Calancha [this message]
2016-04-08 14:06             ` Eli Zaretskii

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=alpine.LRH.2.20.1604060052450.10077@calancha-ilc.kek.jp \
    --to=f92capac@gmail.com \
    --cc=23206@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /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).