Skip to content

fix: find and jq honour -- as end-of-options - #98

Merged
davydog187 merged 1 commit into
mainfrom
cursor/fix-find-jq-end-of-options-98a8
Aug 21, 2026
Merged

fix: find and jq honour -- as end-of-options#98
davydog187 merged 1 commit into
mainfrom
cursor/fix-find-jq-end-of-options-98a8

Conversation

@davydog187

@davydog187 davydog187 commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Fixes #90

Follow-up from #89 / #83. StdinOperand.split_end_of_options/1 already covered most file-operand commands, but find and jq still mishandled --.

User-visible behavior

# before
$ find -- -foo
find: unknown predicate '-foo'    # rc=1

$ printf '{"k":1}\n' | jq -- .
jq: .: Is a directory             # `.` opened as a path

# after
$ find -- -foo
-foo
-foo/x                            # rc=0 when that path exists

$ printf '{"k":1}\n' | jq -- .
{
  "k": 1
}

jq . -- FILE is unchanged. JustBash.exec/2 does not raise.

GNU find still treats find -- -foo as a predicate (a path starting with - ends the starting-point list). This change follows the #90 / ln.ex reading: -- ends parse and the remainder are operands, which is the POSIX reason -- exists.

GNU jq: -- only ends options. The first remaining positional is the filter (default .), then the file.

Changes

  • find calls split_end_of_options/1 and appends the remainder as paths, so find -- -foo searches -foo.
  • jq collects leftover positionals from before -- and concatenates them with the extra tokens after it: filter, then file. jq -- . no longer opens . as a path.
  • Tests for find -- -foo, jq -- ., and extra -- placements (only arg, file named --, -- between two operands).

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Testing

  • Added new tests
  • All existing tests pass

Local gates:

mix compile --warnings-as-errors
mix format --check-formatted
mix credo            # clean
mix credo --strict   # only the pre-existing apply/2 test fixture
mix test
# Finished in 39.1 seconds
# 2 doctests, 62 properties, 5488 tests, 0 failures (5 excluded)
mix docs --warnings-as-errors
mix dialyzer
# Total errors: 13, Skipped: 13, Unnecessary Skips: 0

Checklist

  • My code follows the style guidelines of this project
  • I have run mix format
  • I have run mix credo and addressed any issues
  • I have added tests that prove my fix is effective
  • New and existing tests pass locally with my changes
  • I have updated the CHANGELOG.md
Open in Web Open in Cursor 

find -- -foo was still parsed as a predicate. jq -- . opened `.` as a
file. Split at `--` and treat the remainder as operands: paths for find,
filter then file for jq. exec/2 returns a result either way.

Co-authored-by: Dave Lucia <davelucianyc@gmail.com>
@davydog187
davydog187 marked this pull request as ready for review August 21, 2026 20:45
@davydog187
davydog187 merged commit 0077d63 into main Aug 21, 2026
4 checks passed
@davydog187
davydog187 deleted the cursor/fix-find-jq-end-of-options-98a8 branch August 21, 2026 23:54
This was referenced Aug 21, 2026
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.

find and jq still mishandle -- after the #83 sweep

2 participants