unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#11815: 24.1; Confusing behavior of & in Dired
@ 2012-06-29  8:29 John Wiegley
  2012-07-11  9:21 ` Juri Linkov
  0 siblings, 1 reply; 3+ messages in thread
From: John Wiegley @ 2012-06-29  8:29 UTC (permalink / raw)
  To: 11815

If I mark several files in dired and press !, I can execute:

    rsync -av * jw:/srv/ftp/pub

I can also run:

    rsync -av * jw:/srv/ftp/pub &

But if I type &, I cannot run:

    rsync -av * jw:/srv/ftp/pub

Because this is equivalent to:

    rsync -av * jw:/srv/ftp/pub * &

It actually decribes this behavior in the docstring: with the & command, if no
& appears at the end of the line (which makes little sense, since I pressed &
to indicate it was asynchronous), Dired adds "* &".  ??

I think that the following equivalence should hold:

    ! COMMAND & == & COMMAND

The fix is simply to change the two lines in `dired-do-async-shell-command'
which append " *" to the end of the line to read:

  (unless (string-match "[ \t][*?][ \t]" command)
    (setq command (concat command " *")))

Thanks,
  John

In GNU Emacs 24.1.1 (x86_64-apple-darwin11.4.0, Carbon Version 1.6.0 AppKit 1138.47)
 of 2012-06-28 on vulcan.local





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

* bug#11815: 24.1; Confusing behavior of & in Dired
  2012-06-29  8:29 bug#11815: 24.1; Confusing behavior of & in Dired John Wiegley
@ 2012-07-11  9:21 ` Juri Linkov
  2012-07-12  8:47   ` Juri Linkov
  0 siblings, 1 reply; 3+ messages in thread
From: Juri Linkov @ 2012-07-11  9:21 UTC (permalink / raw)
  To: 11815

> I think that the following equivalence should hold:
>
>     ! COMMAND & == & COMMAND

The problem is that the equivalence should be rather following:

    & COMMAND == ! COMMAND * &

because the file names should be stuffed before the ampersand.

And also:

    & COMMAND * == ! COMMAND * &

    & COMMAND * ARG2 == ! COMMAND * ARG2 &

A reliable fix consistent with the usage of `*' and `?' would be:

=== modified file 'lisp/dired-aux.el'
--- lisp/dired-aux.el	2012-04-17 01:52:00 +0000
+++ lisp/dired-aux.el	2012-07-11 09:11:48 +0000
@@ -556,8 +556,9 @@ (defun dired-do-async-shell-command (com
       (dired-read-shell-command "& on %s: " current-prefix-arg files)
       current-prefix-arg
       files)))
-  (unless (string-match "[*?][ \t]*\\'" command)
-    (setq command (concat command " *")))
+  (if (and (not (string-match dired-quark-subst-regexp command))
+	   (not (string-match dired-star-subst-regexp command)))
+      (setq command (concat command " *")))
   (unless (string-match "&[ \t]*\\'" command)
     (setq command (concat command " &")))
   (dired-do-shell-command command arg file-list))

But then what to do with `?'?

    & COMMAND ? == ! COMMAND FILE1 & COMMAND FILE2 &

or

    & COMMAND ? == ! COMMAND FILE1 ; COMMAND FILE2 &

This is why we have bug#10598.

The following comment in dired-aux.el provides a useful hint
about the history of this function:

  ;; The in-background argument is only needed in Emacs 18 where
  ;; shell-command doesn't understand an appended ampersand `&'.

`in-background' is the former argument of `dired-do-shell-command'
removed by revno 911.  It could be revived, but its drawback is that
this argument should be added to many functions.





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

* bug#11815: 24.1; Confusing behavior of & in Dired
  2012-07-11  9:21 ` Juri Linkov
@ 2012-07-12  8:47   ` Juri Linkov
  0 siblings, 0 replies; 3+ messages in thread
From: Juri Linkov @ 2012-07-12  8:47 UTC (permalink / raw)
  To: 11815

merge 11815 10598
thanks

I'm merging this with bug#10598 because they both can be fixed
with one patch that completely removes these two lines
from `dired-do-async-shell-command':

  (unless (string-match "[*?][ \t]*\\'" command)
    (setq command (concat command " *")))

and takes care about handling this case in `dired-shell-stuff-it'.





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

end of thread, other threads:[~2012-07-12  8:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-29  8:29 bug#11815: 24.1; Confusing behavior of & in Dired John Wiegley
2012-07-11  9:21 ` Juri Linkov
2012-07-12  8:47   ` Juri Linkov

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