#1025331 tar: needs an unambiguous listing format

Package:
tar
Source:
tar
Description:
GNU version of the tar archiving utility
Submitter:
Matthew Vernon
Date:
2025-08-22 16:57:02 UTC
Severity:
normal
Tags:
#1025331#5
Date:
2022-12-02 16:52:23 UTC
From:
To:
Hi,

I discovered while working on #1010024 that tar (since version 1.30)
lacks an unambiguous listing format, by which I mean an output of tar -t
that one can then pass to tar -x and will correctly represent all legal
paths.

The natural approach, I think, would be to have an argument something
like -print0 that could then be passed to tar --null

Currently, tar listings may be quoted or unquoted.

Unquoted paths are ambiguous, because you don't know if a newline
represents a newline in a path or is a separator between paths.

Quoted paths are unambiguous; however since tar 1.30,
--verbatim-files-from (which is necessary to cope with paths starting - 
which are otherwise treated as command-line arguments) does not unquote
paths.

So if you (might) have paths that start - and paths that contain
newlines, you can't win. This is what caused a lot of pain in pristine-tar.

It used to be possible to correctly and unambiguously use quoted paths
and --verbatim-files-from together (and pristine-tar did so) because
--verbatim-files-from would unquote. That was broken with the following 
change in tar (which went into 1.30):

"
2017-11-09  Sergey Poznyakoff  <gray@gnu.org.ua>

         Fix --verbatim-files-from

         * src/names.c (read_next_name): Don't unquote name read from the
         file, if --verbatim-files-from option is in effect.
         (names_options): improve description of --verbatim-files-from
"

Regards,

Matthew