Support POSIX-style tar keystring syntax (no leading dash)#1
Closed
Support POSIX-style tar keystring syntax (no leading dash)#1
Conversation
Co-authored-by: kaladron <377531+kaladron@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Adapt command-line parsing for tar functionality
Support POSIX-style tar keystring syntax (no leading dash)
Mar 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
POSIX specifies
tar key [file...]where the first operand is a keystring with no-prefix (e.g.tar cvf archive.tar files), but the implementation only accepted GNU-style dash-prefixed flags.Approach
Rather than rewriting the clap argument definitions, the args vector is pre-processed before clap sees it: if
args[1]is a valid POSIX keystring it is expanded in-place into equivalent dash-prefixed flags.The
fandbmodifiers consume file operands in key-character order, matching the POSIX ordering requirement. Both styles remain fully supported.Changes
is_posix_keystring(s)— detects a valid keystring: no leading-, at least one function letter (c x t u r), all chars from the recognised key-character set.expand_posix_keystring(args)— rewritesVec<OsString>whenargs[1]is a keystring;fandbconsume positional file operands in order; remaining operands pass through unchanged.uumain— callsexpand_posix_keystringafter the existing util-name-skipping step.Tests
is_posix_keystringandexpand_posix_keystringcovering acceptance, rejection, and expansion edge cases.cf,cvf,xf,xvfend-to-end, plus a round-trip assertion that POSIX and dash-prefix styles produce bit-identical archives.💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.