Bash-compatible parsing (PR #24) + 0.4.0 docs and coverage - #28
Merged
Merged
Conversation
Rewrote the parser to use a character-by-character state machine instead of complex regex. This properly handles adjacent quoted and unquoted segments as a single argument, matching Bash behavior. Examples of now-correct parsing: - `--foo="bar"'baz'` → `--foo=barbaz` - `a" b"` → `a b` - `run:silent["echo 1"]["echo 2"]` → `run:silent[echo 1][echo 2]` Also fixed existing test cases that had incorrect expectations and added new test cases for combined quotation segments.
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.
Builds on #24 (this branch is based on
TooTallNate:fix/inner-word-quotes, so its two commits are included in the diff below) and adds the release/docs/test follow-up needed to merge it.Parser change (from #24, by @TooTallNate)
Rewrites the parser as a character-by-character state machine instead of regex, so adjacent quoted and unquoted segments form a single argument and quote characters are stripped everywhere, matching bash word-splitting:
--foo="bar"'baz'->--foo=barbaza" b"->a b(fixes doesn't strip word-internal quotes #20)"a"b->ab(fixes separates unquoted tail of argument starting with quotes #23)run:silent["echo 1"]["echo 2"]->run:silent[echo 1][echo 2]--name='Phil Taylor'->--name=Phil TaylorVerified against real bash (5.3): new output matches bash for all of the above. Remaining divergences are pre-existing and unchanged: backslash escapes are not processed,
$variables/globs stay literal, unclosed quotes consume the rest of the input instead of erroring.Follow-up in this PR
test:12 new active specs covering the merged-quotation behavior (incl. the exact separates unquoted tail of argument starting with quotes #23 case, empty-quote edge cases""foo/foo""/foo""bar, the parens variant, whitespace/tab robustness) plus 1 pendingxitTODO for backslash escapes.docs:README output block fixed for quote-stripping, new "Parsing behavior" section, CHANGELOG0.4.0entry (also documents everything since0.3.1: 0.3.2 bump, TS 5.0.4, CI, minimatch/brace-expansion security bumps),package.json/package-lock.jsonbumped to0.4.0.Test plan
npm test(build + jasmine): 33 specs, 0 failures, 1 pending (the backslash TODO).