GNU bug report logs - #29094
dired-do-compress creates empty archives

Previous Next

Package: emacs;

Reported by: Max <mu <at> magi.net.ru>

Date: Wed, 1 Nov 2017 00:02:02 UTC

Severity: normal

Tags: fixed, patch

Fixed in version 26.1

Done: Noam Postavsky <npostavs <at> users.sourceforge.net>

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 29094 in the body.
You can then email your comments to 29094 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#29094; Package emacs. (Wed, 01 Nov 2017 00:02:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Max <mu <at> magi.net.ru>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 01 Nov 2017 00:02:02 GMT) Full text and rfc822 format available.

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

From: Max <mu <at> magi.net.ru>
To: bug-gnu-emacs <at> gnu.org
Subject: dired-do-compress creates empty archives
Date: Wed, 1 Nov 2017 02:33:59 +0300
Hi,

When Z is pressed on a directory, dired (according to
dired-compress-file-suffixes variable) runs the following command:

tar -c directory | gzip -c9 > directory.tar.gz

On my system running this command results in an error:

tar: Failed open to write on /dev/rst0: Permission denied

as tar(1) defaults -f to /dev/rst0.

Argument '-f-' should be used to write to stdout.

Also '-v' is probably not needed here, since the output is not used
anywhere.

Here is a patch to correct this behaviour:

diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 94938cf679..14f4be07be 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -974,8 +974,8 @@ command with a prefix argument (the value does not matter)."
     ;; "tar -zxf" isn't used because it's not available on the
     ;; Solaris10 version of tar. Solaris10 becomes obsolete in 2021.
     ;; Same thing on AIX 7.1.
-    ("\\.tar\\.gz\\'" "" "gzip -dc %i | tar -xv")
-    ("\\.tgz\\'" "" "gzip -dc %i | tar -xv")
+    ("\\.tar\\.gz\\'" "" "gzip -dc %i | tar -xf -")
+    ("\\.tgz\\'" "" "gzip -dc %i | tar -xf -")
     ("\\.gz\\'" "" "gunzip")
     ("\\.Z\\'" "" "uncompress")
     ;; For .z, try gunzip.  It might be an old gzip file,
@@ -990,7 +990,7 @@ command with a prefix argument (the value does not matter)."
     ;; This item controls naming for compression.
     ("\\.tar\\'" ".tgz" nil)
     ;; This item controls the compression of directories
-    (":" ".tar.gz" "tar -c %i | gzip -c9 > %o"))
+    (":" ".tar.gz" "tar -cf - %i | gzip -c9 > %o"))
   "Control changes in file name suffixes for compression and uncompression.
 Each element specifies one transformation rule, and has the form:
   (REGEXP NEW-SUFFIX PROGRAM)
@@ -1007,9 +1007,9 @@ Otherwise, the rule is a compression rule, and compression is done with gzip.
 ARGS are command switches passed to PROGRAM.")
 
 (defvar dired-compress-files-alist
-  '(("\\.tar\\.gz\\'" . "tar -c %i | gzip -c9 > %o")
-    ("\\.tar\\.bz2\\'" . "tar -c %i | bzip2 -c9 > %o")
-    ("\\.tar\\.xz\\'" . "tar -c %i | xz -c9 > %o")
+  '(("\\.tar\\.gz\\'" . "tar -cf - %i | gzip -c9 > %o")
+    ("\\.tar\\.bz2\\'" . "tar -cf - %i | bzip2 -c9 > %o")
+    ("\\.tar\\.xz\\'" . "tar -cf - %i | xz -c9 > %o")
     ("\\.zip\\'" . "zip %o -r --filesync %i"))
   "Control the compression shell command for `dired-do-compress-to'.
 





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29094; Package emacs. (Tue, 05 Dec 2017 01:47:02 GMT) Full text and rfc822 format available.

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

From: Noam Postavsky <npostavs <at> users.sourceforge.net>
To: Max <mu <at> magi.net.ru>
Cc: 29094 <at> debbugs.gnu.org
Subject: Re: bug#29094: dired-do-compress creates empty archives
Date: Mon, 04 Dec 2017 20:46:07 -0500
tags 29094 + patch
quit

Max <mu <at> magi.net.ru> writes:

> When Z is pressed on a directory, dired (according to
> dired-compress-file-suffixes variable) runs the following command:
>
> tar -c directory | gzip -c9 > directory.tar.gz
>
> On my system running this command results in an error:
>
> tar: Failed open to write on /dev/rst0: Permission denied
>
> as tar(1) defaults -f to /dev/rst0.
>
> Argument '-f-' should be used to write to stdout.

Right, the GNU tar manual says [1]

    By default, tar uses an archive file name that was compiled when it was
    built on the system; usually this name refers to some physical tape
    drive on the machine. However, the person who installed tar on the
    system may not have set the default to a meaningful value as far as most
    users are concerned.

So it's actually a bit surprising that the current values apparently
work for most people.  I guess most GNU/Linux distros set the default to
stdin?

As far as I can tell, dropping the 'f' option was just an oversight (see
[2] and other messages in that thread).

> Also '-v' is probably not needed here, since the output is not used
> anywhere.

Makes sense.

> Here is a patch to correct this behaviour:

I think it's good for emacs-26.  I assume you haven't assigned copyright
to Emacs (so it should be marked as a tiny change)?

[1]: https://www.gnu.org/software/tar/manual/html_node/file.html
[2]: https://lists.gnu.org/archive/html/emacs-devel/2015-10/msg01282.html 




Added tag(s) patch. Request was from Noam Postavsky <npostavs <at> users.sourceforge.net> to control <at> debbugs.gnu.org. (Tue, 05 Dec 2017 01:47:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29094; Package emacs. (Thu, 07 Dec 2017 03:26:01 GMT) Full text and rfc822 format available.

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

From: Max <mu <at> magi.net.ru>
To: Noam Postavsky <npostavs <at> users.sourceforge.net>
Cc: 29094 <at> debbugs.gnu.org
Subject: Re: bug#29094: dired-do-compress creates empty archives
Date: Thu, 7 Dec 2017 06:25:23 +0300
Noam Postavsky writes:

> So it's actually a bit surprising that the current values apparently
> work for most people.  I guess most GNU/Linux distros set the default
> to stdin?

I've investigated this a bit further. There is a DEFAULT_ARCHIVE
variable in GNU tar which is set at configuration time. The default
is '-'. Most distributions probably use the defaults.

In OpenBSD [1] and FreeBSD [2] makefiles for GNU tar DEFAULT_ARCHIVE
set to point to a tape drive. Probably to be consistent with tar(1)
provided in the base system which is also points to a tape drive.

> I assume you haven't assigned copyright to Emacs (so it should be
> marked as a tiny change)?

I haven't yet. As far as I know, these kind of small patches are
accepted without assigning a copyright. If not, please, let me know.

[1]: https://cvsweb.openbsd.org/cgi-bin/cvsweb/ports/archivers/gtar/Makefile?rev=1.78
[2]: https://svnweb.freebsd.org/ports/head/archivers/gtar/Makefile?revision=421635




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29094; Package emacs. (Fri, 08 Dec 2017 09:53:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Noam Postavsky <npostavs <at> users.sourceforge.net>
Cc: 29094 <at> debbugs.gnu.org, mu <at> magi.net.ru
Subject: Re: bug#29094: dired-do-compress creates empty archives
Date: Fri, 08 Dec 2017 11:51:49 +0200
> From: Noam Postavsky <npostavs <at> users.sourceforge.net>
> Date: Mon, 04 Dec 2017 20:46:07 -0500
> Cc: 29094 <at> debbugs.gnu.org
> 
> So it's actually a bit surprising that the current values apparently
> work for most people.  I guess most GNU/Linux distros set the default to
> stdin?

It's that, and also these commands are probably rarely used.

> I think it's good for emacs-26.

Yes.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29094; Package emacs. (Fri, 08 Dec 2017 09:54:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Max <mu <at> magi.net.ru>
Cc: 29094 <at> debbugs.gnu.org, npostavs <at> users.sourceforge.net
Subject: Re: bug#29094: dired-do-compress creates empty archives
Date: Fri, 08 Dec 2017 11:53:05 +0200
> Date: Thu, 7 Dec 2017 06:25:23 +0300
> From: Max <mu <at> magi.net.ru>
> Cc: 29094 <at> debbugs.gnu.org
> 
> > I assume you haven't assigned copyright to Emacs (so it should be
> > marked as a tiny change)?
> 
> I haven't yet. As far as I know, these kind of small patches are
> accepted without assigning a copyright.

True.  (But what matters is the sum total of your contributions, so
enough such small patches will still exhaust your grace amount.)

Thanks.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29094; Package emacs. (Mon, 11 Dec 2017 23:49:01 GMT) Full text and rfc822 format available.

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

From: Noam Postavsky <npostavs <at> users.sourceforge.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 29094 <at> debbugs.gnu.org, mu <at> magi.net.ru
Subject: Re: bug#29094: dired-do-compress creates empty archives
Date: Mon, 11 Dec 2017 18:48:40 -0500
tags 29094 fixed
close 29094 26.1
quit

Eli Zaretskii <eliz <at> gnu.org> writes:

>> I think it's good for emacs-26.
>
> Yes.

Pushed to emacs-26.

[1: cd53b6399b]: 2017-12-11 17:38:28 -0500
  Fix dired-do-compress when tar doesn't default to stdin (Bug#29094)
  https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=cd53b6399b187f5a6719dd58a489f4c55fd094aa




Added tag(s) fixed. Request was from Noam Postavsky <npostavs <at> users.sourceforge.net> to control <at> debbugs.gnu.org. (Mon, 11 Dec 2017 23:49:03 GMT) Full text and rfc822 format available.

bug marked as fixed in version 26.1, send any further explanations to 29094 <at> debbugs.gnu.org and Max <mu <at> magi.net.ru> Request was from Noam Postavsky <npostavs <at> users.sourceforge.net> to control <at> debbugs.gnu.org. (Mon, 11 Dec 2017 23:49:03 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. (Tue, 09 Jan 2018 12:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 107 days ago.

Previous Next


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