fix: honour -- as end-of-options for file-operand commands - #89
Merged
Conversation
POSIX `--` ends option parsing; everything after it is an operand. Commands that used FlagParser or StdinOperand.operands already did this; hand-rolled parsers treated `--` as a filename or an invalid option. The worst case was split-brain: `shasum -- /f` printed the correct hash and still exited 1. Split once at the parser entry point and append the remainder as operands, and enumerate `cmd -- FILE` for every Registry command that takes a file operand so a new command cannot skip the rule. Co-authored-by: Dave Lucia <davelucianyc@gmail.com>
Dialyzer flagged the is_integer/1 guard as never succeeding because command arguments are binaries. The remaining Integer.parse/1 clause is the one that was already used. Co-authored-by: Dave Lucia <davelucianyc@gmail.com>
davydog187
marked this pull request as ready for review
August 21, 2026 17:13
This was referenced Aug 21, 2026
9 tasks
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.
Fixes #83
POSIX
--ends option parsing; everything after it is an operand. Some commands already did that (sort,wc,head,tac,rev). Others treated--as a filename or rejected it as an invalid option.The worst case was split-brain:
shasum -- /fprinted the correct hash and exited 1 withshasum: --: No such file or directory, so a caller checking the exit code and a caller reading stdout disagreed about whether it worked.User-visible behavior
--is also how a filename beginning with a dash is passed:cat -- -freads a file named-f.JustBash.exec/2does not raise.Changes
StdinOperand.split_end_of_options/1is the shared--stop thatFlagParserandStdinOperand.operands/1already implemented. Hand-rolled parsers call it once at their entry point, parse flags from the left side, and append the remainder as operands.cat,touch,mv,source) drop--rather than opening a path named--.test/commands/end_of_options_test.exsenumeratescmd -- FILEfor every Registry command that takes a file operand, with an explicit skip-and-reason for the rest, so a new command cannot join unclassified.Type of Change
Testing
Local gates:
Checklist
mix formatmix credoand addressed any issues