Repository navigation
sed: make the v command work on input and in scripts - #622
jayhemnani9910 wants to merge 2 commits into
Conversation
`v` compiled to a command the processor did not know, so any script
with `v` panicked ("invalid command code") on the first input line. The
version also ran to the end of the line, so `v;p`, `v 4.2;p` and `{v}`
failed with "invalid version of sed", and the parts were compared one
by one against 4.9.0, which rejected 4.2.2 and 3.10.
Do nothing for `v` at run time, end the version at a blank, ';' or '}',
and compare it with 4.9 part by part, as GNU sed does.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #622 +/- ##
==========================================
+ Coverage 95.07% 95.46% +0.38%
==========================================
Files 14 14
Lines 7436 7713 +277
Branches 439 458 +19
==========================================
+ Hits 7070 7363 +293
+ Misses 365 349 -16
Partials 1 1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| Err(_) => compilation_error(lines, line, "invalid version of sed"), | ||
| }, | ||
| Err(_) => compilation_error(lines, line, "invalid version of sed"), | ||
| line.eat_spaces(); |
There was a problem hiding this comment.
the main loop already skips blanks and ;, do we need these lines?
There was a problem hiding this comment.
No, removed in 39d9632. v;p, v 4.2 p and {v;p} still pass.
| new_ucmd!().args(&[version]).succeeds(); | ||
| } | ||
| for version in ["v4.9.0", "v4.9.1", "v5"] { | ||
| new_ucmd!() |
There was a problem hiding this comment.
could you please add v4.9 to the passing list and v4.10 to the failing one? both are in the description
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
vpanics as soon as there is input:The existing tests only run
vwith no input, so they don't reach the processor. Two more problems in the compiler:v;p,v 4.2;pand{v}fail with "invalid version of sed";minor <= 9 && patch == 0), sov 4.2.2andv 3.10fail with "expected newer version of sed", though both are older than 4.9.The processor now does nothing for
v, like:. The version ends at a blank,;or}, and it is compared with 4.9 part by part. I checked these against GNU sed 4.9 and they all match:v,v;p,v 4.2;p,v 4.2 p,{v},{v;p},v4.2,v 4.2.2,v 3.10,v 1.2.3.4andv 4.9succeed;v 4.9.0,v 4.9.1,v 4.10andv 5fail with "expected newer version of sed". Not changed: a non-numeric version likev abc, or a part above 255 likev999, still gives "invalid version of sed" (GNU says "expected newer version"). That is whattest_invalid_only_major_versionexpects. An address beforevis still rejected.Tests:
test_version_with_input,test_version_followed_by_commandandtest_version_compared_part_by_partfail without the change.cargo test: 357 passed (354 on main), clippy clean.