Skip to content

Support POSIX-style tar keystring syntax (no leading dash)#1

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/adapt-command-line-parsing
Closed

Support POSIX-style tar keystring syntax (no leading dash)#1
Copilot wants to merge 2 commits intomainfrom
copilot/adapt-command-line-parsing

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 9, 2026

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.

tar cvf archive.tar file.txt   →   tar -c -v -f archive.tar file.txt
tar xvf archive.tar            →   tar -x -v -f archive.tar

The f and b modifiers 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) — rewrites Vec<OsString> when args[1] is a keystring; f and b consume positional file operands in order; remaining operands pass through unchanged.
  • uumain — calls expand_posix_keystring after the existing util-name-skipping step.
  • USAGE string — updated to show both invocation forms.

Tests

  • 13 unit tests for is_posix_keystring and expand_posix_keystring covering acceptance, rejection, and expansion edge cases.
  • 5 integration tests: cf, cvf, xf, xvf end-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.

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
@kaladron kaladron closed this Mar 11, 2026
@kaladron kaladron deleted the copilot/adapt-command-line-parsing branch March 11, 2026 08:18
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