From: Gregory Heytings <gregory@heytings.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: mvar.40k@gmail.com, larsi@gnus.org, mcenturion@fing.edu.uy,
arthur.miller@live.com, 47058@debbugs.gnu.org
Subject: bug#47058: 28.0.50; Dired Z: insert-directory: Reading directory: No such file or directory, CrossLine_linux_x86
Date: Tue, 21 Sep 2021 20:48:29 +0000 [thread overview]
Message-ID: <052fb8a67e6d185de0cc@heytings.org> (raw)
In-Reply-To: <052fb8a67e886712c3e6@heytings.org>
[-- Attachment #1: Type: text/plain, Size: 371 bytes --]
>>> Would it not be easier to unconditionally untar the contents in a
>>> temporary directory, and to either move its contents to the current
>>> directory if it contains only one entry, or to rename it to a
>>> directory based on the tar file name when it contains more than one
>>> entry?
>>
>> Easier in what sense?
>
> In the sense of "DWIM".
>
Patch attached.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-diff; name=Uncompress-tar-files-in-a-DWIMish-way.patch, Size: 3287 bytes --]
From 7a25f95b2a554ca281bb0e6d5000ef9ece980694 Mon Sep 17 00:00:00 2001
From: Gregory Heytings <gregory@heytings.org>
Date: Tue, 21 Sep 2021 20:43:27 +0000
Subject: [PATCH] Uncompress tar files in a DWIMish way
* lisp/dired-aux.el (dired-compress-file-suffixes): Add a '-C %o'
argument to tar commands.
(dired-compress-file): Extract files in a temporary directory; if
it contains a single file, use it as the output file, otherwise
rename the temporary directory and use it as the output file.
---
lisp/dired-aux.el | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 53fbcfb6d0..66422e7b16 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -1134,9 +1134,9 @@ dired-compress-file-suffixes
;; "tar -zxf" isn't used because it's not available on the
;; Solaris 10 version of tar (obsolete in 2024?).
;; Same thing on AIX 7.1 (obsolete 2023?) and 7.2 (obsolete 2022?).
- ("\\.tar\\.gz\\'" "" "gzip -dc %i | tar -xf -")
- ("\\.tar\\.xz\\'" "" "xz -dc %i | tar -xf -")
- ("\\.tgz\\'" "" "gzip -dc %i | tar -xf -")
+ ("\\.tar\\.gz\\'" "" "gzip -dc %i | tar -C %o -xf -")
+ ("\\.tar\\.xz\\'" "" "xz -dc %i | tar -C %o -xf -")
+ ("\\.tgz\\'" "" "gzip -dc %i | tar -C %o -xf -")
("\\.gz\\'" "" "gzip -d")
("\\.lz\\'" "" "lzip -d")
("\\.Z\\'" "" "uncompress")
@@ -1148,8 +1148,8 @@ dired-compress-file-suffixes
("\\.bz2\\'" "" "bunzip2")
("\\.xz\\'" "" "unxz")
("\\.zip\\'" "" "unzip -o -d %o %i")
- ("\\.tar\\.zst\\'" "" "unzstd -c %i | tar -xf -")
- ("\\.tzst\\'" "" "unzstd -c %i | tar -xf -")
+ ("\\.tar\\.zst\\'" "" "unzstd -c %i | tar -C %o -xf -")
+ ("\\.tzst\\'" "" "unzstd -c %i | tar -C %o -xf -")
("\\.zst\\'" "" "unzstd --rm")
("\\.7z\\'" "" "7z x -aoa -o%o %i")
;; This item controls naming for compression.
@@ -1278,15 +1278,23 @@ dired-compress-file
nil)
((and suffix (setq command (nth 2 suffix)))
(if (string-match "%[io]" command)
- (prog1 (setq newname (file-name-as-directory newname))
+ (let ((tmp (file-name-as-directory (make-temp-file newname t))))
(dired-shell-command
(replace-regexp-in-string
- "%o" (shell-quote-argument newname)
+ "%o" (shell-quote-argument tmp)
(replace-regexp-in-string
"%i" (shell-quote-argument file)
command
nil t)
- nil t)))
+ nil t))
+ (let ((files (directory-files
+ tmp nil
+ directory-files-no-dot-files-regexp)))
+ (if (> (length files) 1)
+ (rename-file tmp newname)
+ (rename-file (concat tmp (car files)) newname)
+ (delete-directory tmp)))
+ (file-name-as-directory newname))
;; We found an uncompression rule.
(let ((match (string-search " " command))
(msg (concat "Uncompressing " file)))
--
2.33.0
next prev parent reply other threads:[~2021-09-21 20:48 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-10 20:26 bug#47058: 28.0.50; Dired Z: insert-directory: Reading directory: No such file or directory, CrossLine_linux_x86 Jean Louis
2021-08-31 21:33 ` Marco Centurion
2021-08-31 22:12 ` Arthur Miller
2021-09-01 13:59 ` Marco Centurion - URI
2021-09-01 16:06 ` Arthur Miller
2021-09-20 22:12 ` Michalis V.
2021-09-21 4:32 ` Lars Ingebrigtsen
2021-09-21 8:24 ` Eli Zaretskii
2021-09-21 9:18 ` Michalis V.
2021-09-21 9:32 ` Eli Zaretskii
2021-09-21 17:10 ` Lars Ingebrigtsen
[not found] ` <83a6k5yfrb.fsf@gnu.org>
2021-09-21 17:58 ` Lars Ingebrigtsen
2021-09-21 18:38 ` Gregory Heytings
2021-09-21 18:43 ` Eli Zaretskii
2021-09-21 19:19 ` Gregory Heytings
2021-09-21 20:11 ` Michalis V.
2021-09-21 20:48 ` Gregory Heytings [this message]
2021-09-22 5:40 ` Eli Zaretskii
2021-09-22 7:15 ` Gregory Heytings
2021-09-22 7:54 ` Eli Zaretskii
2021-09-22 8:07 ` Gregory Heytings
2021-09-21 17:07 ` Lars Ingebrigtsen
2021-09-21 20:43 ` Michalis V.
2021-09-22 6:00 ` Eli Zaretskii
2021-09-21 8:25 ` Michael Albinus
2021-09-21 9:24 ` Michalis V.
2021-09-21 12:06 ` Michael Albinus
2022-03-11 8:29 ` Michael Albinus
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=052fb8a67e6d185de0cc@heytings.org \
--to=gregory@heytings.org \
--cc=47058@debbugs.gnu.org \
--cc=arthur.miller@live.com \
--cc=eliz@gnu.org \
--cc=larsi@gnus.org \
--cc=mcenturion@fing.edu.uy \
--cc=mvar.40k@gmail.com \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.