Subject: bug#66532: closed (Re: bug#66532: 29.1; dired-guess-default command for tar.zst file fails)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 25 Oct 2023 13:35:02 +0000

Your bug report

#66532: 29.1; dired-guess-default command for tar.zst file fails

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
66532: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=66532
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#66532: 29.1; dired-guess-default command for tar.zst file fails
From: Eli Zaretskii <[email-masked]>
To: Michael Eliachevitch <[email-masked]>
Cc: [email-masked]
Date: Wed, 25 Oct 2023 16:33:17 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Michael Eliachevitch <[email-masked]>
> Cc: [email-masked]
> Date: Sat, 14 Oct 2023 18:41:52 +0000
> 
> 
> 
> > Does the patch below fix this?
> >
> > diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
> > index fc3f6f4..458acad 100644
> > --- a/lisp/dired-aux.el
> > +++ b/lisp/dired-aux.el
> > @@ -1172,7 +1172,7 @@ dired-guess-shell-alist-default
> >           "unxz")
> >
> >     ;; zstandard archives
> > -   `(,(rx (or ".tar.zst" ".tzst") eos) "unzstd -c %i | tar -xf -")
> > +   `(,(rx (or ".tar.zst" ".tzst") eos) "unzstd -c * | tar -xf -")
> >     `(,(rx ".zst" eos)                  "unzstd --rm")
> >
> >     '("\\.shar\\.Z\\'" "zcat * | unshar")
> 
> 
> Yes, this patch works for me for a single tar.zst archive.
> 
> However, when I mark multiple tar.zst archives and then run the
> suggested shell command (with *) on all of them, only the first archive
> gets extracted.. I just opened the Emacs manual dired section and found
> the `?' is a placeholder for which the command gets executed separately
> for each marked file. So with
> 
>     unzstd -c ? | tar -xf -
> 
> each marked archive gets successfully extracted. Here also formatted as a patch;
> 
> diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
> index 2ff620065a5..e0bcae6b005 100644
> --- a/lisp/dired-aux.el
> +++ b/lisp/dired-aux.el
> @@ -1176,7 +1176,7 @@ dired-guess-shell-alist-default
>           "unxz")
> 
>     ;; zstandard archives
> -   `(,(rx (or ".tar.zst" ".tzst") eos) "unzstd -c %i | tar -xf -")
> +   `(,(rx (or ".tar.zst" ".tzst") eos) "unzstd -c ? | tar -xf -")
>     `(,(rx ".zst" eos)                  "unzstd --rm")
> 
>     '("\\.shar\\.Z\\'" "zcat * | unshar")
> 
> I am just wondering that I didn't find the questionmark placeholder in
> any of the other suggested commands for compressed tar files, not sure
> if they work fur multiple marked files, I didn't test that.

Thanks, I installed your variant on the emacs-29 branch, and I'm
therefore closing this bug.

Subject: 29.1; dired-guess-default command for tar.zst file fails
From: Michael Eliachevitch <[email-masked]>
To: [email-masked]
Date: Fri, 13 Oct 2023 11:54:00 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

I tried to extract the attached zstandard-compressed tar archive
`testdir.tar.zst' using the dired-guess-default suggested shell command,
which is

    unzstd -c %i | tar -xf -

It fails with the message

    zstd: can't stat %i : No such file or directory -- ignored
    tar: This does not look like a tar archive
    tar: testdir.tar.zst: Not found in archive

What instead works is using the command

  tar --use-compress-program=unzstd -xvf

My GNU tar version also is able to automatically detect zstandard files,
so basically just "tar -xvf" is suffisient, but the version with
"--use-compress-program=unzstd" is backwards-compatible to older tar
versions.

I suggest fixing that in `dired-guess-shell-alist-default'. Though there
might be tar versions out there which don't support
`--use-compress-program' (I don't know), then maybe a piping solution
might be better, but that should be done in a way that avoid the above
error (not sure what actually causes it).

I use GNU tar version 1.35 and unzstd version v1.5.5.
---

In GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38,
cairo version 1.17.8)
System Description: Arch Linux

Configured using:
 'configure --with-pgtk --with-native-compilation=aot --sysconfdir=/etc
 --prefix=/usr --libexecdir=/usr/lib --with-tree-sitter
 --localstatedir=/var --with-cairo --disable-build-details
 --with-harfbuzz --with-libsystemd --with-modules 'CFLAGS=-march=x86-64
 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2
 -Wformat -Werror=format-security -fstack-clash-protection
 -fcf-protection -g
 -ffile-prefix-map=/build/emacs/src=/usr/src/debug/emacs -flto=auto'
 'LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto=auto'
 'CXXFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions
 -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security
 -fstack-clash-protection -fcf-protection -Wp,-D_GLIBCXX_ASSERTIONS -g
 -ffile-prefix-map=/build/emacs/src=/usr/src/debug/emacs -flto=auto''

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY
PDUMPER PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XIM GTK3 ZLIB

Important settings:
  value of $LC_COLLATE: C.UTF-8
  value of $LC_CTYPE: en_GB.UTF-8
  value of $LC_MESSAGES: en_US.UTF-8
  value of $LC_MONETARY: de_DE.UTF-8
  value of $LC_NUMERIC: en_US.UTF-8
  value of $LC_TIME: de_DE.UTF-8
  value of $LANG: C
  value of $XMODIFIERS: \@im=fcitx
  locale-coding-system: utf-8-unix

Major mode: Dired by name

Minor modes in effect:
  shell-dirtrack-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  buffer-read-only: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny rfc822
mml mml-sec password-cache epa derived epg rfc6068 epg-config gnus-util
text-property-search time-date mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils shell pcomplete comint ansi-osc
ansi-color ring dired-aux cl-loaddefs comp comp-cstr warnings icons
subr-x rx cl-seq cl-macs gv cl-extra help-mode bytecomp byte-compile
cl-lib dired dired-loaddefs rmc iso-transl tooltip cconv eldoc paren
electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/pgtk-win pgtk-win term/common-win pgtk-dnd tool-bar dnd fontset
image regexp-opt fringe tabulated-list replace newcomment text-mode
lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch
easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify
dynamic-setting system-font-setting font-render-setting cairo gtk pgtk
lcms2 multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 88176 12534)
 (symbols 48 7814 1)
 (strings 32 22832 2092)
 (string-bytes 1 699474)
 (vectors 16 17190)
 (vector-slots 8 350551 18772)
 (floats 8 30 40)
 (intervals 56 440 0)
 (buffers 984 15))