Skip to content

tar: a long option may be any unambiguous prefix of its name - #30

Merged
closer-claudio merged 1 commit into
mainfrom
claudio/20261019-tar-long-abbrev
Oct 19, 2026
Merged

closer-claudio merged 1 commit into
mainfrom
claudio/20261019-tar-long-abbrev

Conversation

@closer-claudio

Copy link
Copy Markdown
Contributor

GNU tar takes any unambiguous prefix of a long option (getopt_long), and bsdtar does too, so tar xz --strip 1 extracts with both; this tar refused it as "unrecognized option '--strip'", exit 64. limen v0.14.0 puts this tar first on the hermetic PATH, where farcloser/tarmac's init pipes a tarball into exactly that command and failed on it (farcloser/tarmac#11).

The long-option parser resolves the given name first: an option's whole name is that option, else the one option it is a prefix of; no option is unrecognized as before, several are "option '--ver' is ambiguous; possibilities: '--verbose' '--version'", GNU tar's wording, exit 64. A whole name wins over the options it prefixes: --file is --file, not ambiguous against --files-from, the one such pair in the tables. The argument rules are unchanged and name the resolved option, as glibc does. An empty name (--=x) is unrecognized under its own spelling. The package doc and the README each gain a sentence.

Tests: TestLongOptionAbbreviation creates with --cre --file --dir --verb --xz --files-from and extracts with --extr --strip 1 and --ext --strip=1 --directory, the tarmac shape; TestUsage gains the unrecognized prefix, two ambiguous ones (--ver, --same) and --=x. Each fails against the previous parser.

gzip and xz under GNU also take prefixes and compress's shared codec parser does not; a sweep of the 36 onboarded repositories found no script relying on it, so that is left as it is.

Created by @apostasie personal assistant

GNU tar takes any unambiguous prefix of a long option (getopt_long), and
bsdtar does too, so "tar xz --strip 1" extracts with both; this tar refused
it as "unrecognized option '--strip'", exit 64. limen v0.14.0 puts this tar
first on the hermetic PATH, where farcloser/tarmac's init pipes a tarball
into exactly that command and failed on it.

The long-option parser resolves the given name first: an option's whole
name is that option, else the one option it is a prefix of; no option is
unrecognized as before, several are "option '--ver' is ambiguous;
possibilities: '--verbose' '--version'", GNU tar's wording, exit 64. A whole
name wins over the options it prefixes: --file is --file, not ambiguous
against --files-from, the one such pair in the tables. The argument rules
are unchanged and name the resolved option, as glibc does. An empty name
(--=x) is unrecognized under its own spelling.

Tests: TestLongOptionAbbreviation creates with --cre --file --dir --verb
--xz --files-from and extracts with --extr --strip 1 and --ext --strip=1
--directory, the tarmac shape; TestUsage gains the unrecognized prefix, two ambiguous ones
(--ver, --same) and --=x. Each fails against the previous parser.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: closer-claudio <[email protected]>
@closer-claudio

Copy link
Copy Markdown
Contributor Author

Reviewed at f7ecb18

@closer-claudio
closer-claudio merged commit 0babe57 into main Oct 19, 2026
12 checks passed
@closer-claudio
closer-claudio deleted the claudio/20261019-tar-long-abbrev branch October 19, 2026 05:42
closer-claudio added a commit to farcloser/limen that referenced this pull request Oct 19, 2026
forkcloser/compress v0.3.0 carries the tar member-subset extraction fix
(forkcloser/compress#24), the long-option prefix
fix (forkcloser/compress#30), seekable xz
(forkcloser/compress#20) and xz v1.1.2
(forkcloser/compress#31); the canonical tool set
pins it, with the checksums regenerated. forkcloser/dot v1.3.1 moves in
.limen/tools/go.mod, lifting its go-graphviz and x/image requirements as
tidy demands.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: closer-claudio <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants