--one-top-level clarifications

Bring back documentation for --one-top-level absolute file names,
and clarify its behavior.  Allow --one-top-level only with
-x, -d, -t.
* src/misc.c (chdir_do): Do not pass -1 to openat.  Simplify now
that open_searchdir_how no longer has RESOLVE_BENEATH when
one_top_level_dir is absolute.  Fix errno confusion in messages.
* src/tar.c (decode_options): Allow --one-top-level only with -x,
-d, and -t.  Do not use RESOLVE_BENEATH if --one-top-level=/foo is
used; this simplifies chdir_do.
This commit is contained in:
Paul Eggert
2026-07-29 23:12:46 -07:00
parent 05f21fe936
commit 941f62b24d
4 changed files with 50 additions and 42 deletions
+10 -7
View File
@@ -3287,14 +3287,14 @@ directory.
@opsummary{one-top-level}
@item --one-top-level[=@var{dir}]
Tells @command{tar} to create a new directory beneath the extraction directory
(or the one passed to @option{-C}) and use it to prevent @command{tar}
from modifying files outside that directory.
If @var{dir} is present, it must be a relative file name.
If it is absent, the name of the new directory
Tells @command{tar} to use a directory beneath the extraction directory
(or the one passed to @option{-C}) to prevent @command{tar}
from accessing files outside that directory.
If @var{dir} is absent, the name of the directory
is the base name of the archive minus any recognized archive suffix.
If multiple @option{-C} options are present,
each has its own subdirectory with the same name.
If @var{dir} is an absolute file name, that is the only such directory;
otherwise, the working directory and the directories specified by
any @option{-C} options each have the named subdirectory.
Any member names that do not begin
with that directory name (after
transformations from @option{--transform} and
@@ -3302,6 +3302,9 @@ transformations from @option{--transform} and
file name suffixes are @samp{.tar}, and any compression suffixes
recognizable by @xref{--auto-compress}.
This option can be used only when extracting, comparing, or reading
from the archive.
@opsummary{overwrite}
@item --overwrite