fix(command_parser): handle negated_command as a transparent container#266
fix(command_parser): handle negated_command as a transparent container#266
negated_command as a transparent container#266Conversation
…correctly intent(command_parser): shell negation operator `!` (negated_command) was not recognized as a transparent container, causing `! grep -q test /dev/null` to be treated as an opaque string that failed to match rules learned(command_parser): tree-sitter-bash parses `! cmd` as a `negated_command` node wrapping the inner command — adding it to the transparent container list (alongside if_statement, while_statement, etc.) is sufficient to fix the issue
There was a problem hiding this comment.
Code Review
This pull request fixes an issue where negated shell commands (e.g., ! grep) were not being parsed correctly, causing them to fail rule matching. The negated_command node is now handled as a transparent container in the command parser, allowing the inner command to be evaluated. The changes include documentation updates and new test cases in both unit and integration tests. A review comment suggests adding a test case for negated pipelines within subshells to ensure robust handling of nested command structures.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #266 +/- ##
=======================================
Coverage 89.50% 89.50%
=======================================
Files 52 52
Lines 10730 10731 +1
=======================================
+ Hits 9604 9605 +1
Misses 1126 1126
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
intent(command_parser): add negated pipeline in subshell test case per Gemini review suggestion to cover nested container interaction intent(docs): add PR link to release notes entry per project convention
Why
!were not evaluated correctly, causing commands that should be allowed to return ask insteadif ! grep -q test /dev/null; then echo no; fidid not match thegrepruleWhat
negated_commandis now handled as a transparent container, allowing inner commands to be correctly extracted and evaluated! cmdas anegated_commandnode, butcollect_commands()did not handle this node typeBefore:
After: