Parse args like shasum #428
Labels
No labels
announcement
bug
build
CI
dependencies
documentation
duplicate
enhancement
experience feedback
feature request
github_actions
help wanted
install
invalid
Long-term
optimization
portability
question
target-specific
test issue
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-Cyan4973/xxHash#428
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Since xxhash is cross-platform compatible, I assume it tries to stay away from using
getopt, whichshasumuses (see coreutilssrc/md5sum.cmain func). The current argument parsing of xxhsum has some bugs and some enhancements it could use:--as end of option parsingFor 1., try
and get
Now, try
and get
I'm pretty sure we don't want to be double-interpreting
--checkas an option and filename.For 2., try
and get
Try
and get
So there appears to be no way to run
xxshumon a file that begins with-. Sure, we can pass it through stdin (e.g.cat -_- | xxhsum), but that's not ideal (and you also need to attach the filename to the output).I tried working on these myself, but it's nontrivial because the current code mostly uses an
intvariablefilenamesStartto determine where to start processing filenames. I don't really have experience withgetopt, but I assume it would be the best solution (but then, we need to find an alternative for Windows systems, use#ifdef _WIN32, etc.).Here are other examples of what
shasumdoes along with their not-workingxxhsumequivalents in comments:The current
xxhsumhas a pretty strong limitation which requires that all commands must appear first on the command line, then all following arguments are interpreted as filenames (that's thefilenamesStartvariable). Changing that restriction to allow files and commands to be provided in any order would require to add some substantial complexity, which I would prefer to avoid.Beyond that, the other suggestions are fair points, and can be provided.
Supporting filenames starting with
-, or interpreting--as "from now on all arguments are filenames" are within reach.