GNU bug report logs - #11815
24.1; Confusing behavior of & in Dired

Previous Next

Package: emacs;

Reported by: "John Wiegley" <johnw <at> newartisans.com>

Date: Fri, 29 Jun 2012 08:37:01 UTC

Severity: normal

Merged with 10598

Found in versions 24.0.92, 24.1

Done: Juri Linkov <juri <at> jurta.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 11815 in the body.
You can then email your comments to 11815 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#11815; Package emacs. (Fri, 29 Jun 2012 08:37:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to "John Wiegley" <johnw <at> newartisans.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 29 Jun 2012 08:37:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "John Wiegley" <johnw <at> newartisans.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.1; Confusing behavior of & in Dired
Date: Fri, 29 Jun 2012 03:29:25 -0500
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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11815; Package emacs. (Wed, 11 Jul 2012 09:34:02 GMT) Full text and rfc822 format available.

Message #8 received at 11815 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: 11815 <at> debbugs.gnu.org
Subject: Re: bug#11815: 24.1; Confusing behavior of & in Dired
Date: Wed, 11 Jul 2012 12:21:23 +0300
> 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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11815; Package emacs. (Thu, 12 Jul 2012 08:56:02 GMT) Full text and rfc822 format available.

Message #11 received at 11815 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: 11815 <at> debbugs.gnu.org
Subject: Re: bug#11815: 24.1; Confusing behavior of & in Dired
Date: Thu, 12 Jul 2012 11:47:34 +0300
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'.




Forcibly Merged 10598 11815. Request was from Juri Linkov <juri <at> jurta.org> to control <at> debbugs.gnu.org. (Thu, 12 Jul 2012 09:06:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 15 Aug 2012 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 312 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.