You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
sed: v command panics when the version check succeeds #669
When the GNU v version assertion succeeds, uutils panics at runtime with invalid command code instead of treating the command as a no-op. The compiler already accepts v and rejects versions newer than 4.9, but the processor has no arm for v, so a script that uses v or v4.9 aborts as soon as there is input.
I found this with behave, by recording GNU sed 4.9 and replaying the cases against uutils sed 0.3.0 (current main).
Reproduction
printf'a\n'| sed 'v'printf'a\n'| sed 'v4.9'
Expected (GNU sed 4.9): print a and exit 0.
Actual (uutils sed 0.3.0): panic at src/sed/processor.rs (invalid command code) and a non-zero exit.
The panic is easy to miss in tests that run sed v with no stdin, because the script compiles and then there is no line to process.
While reproducing this I also hit a few related mismatches that belong with the same command:
v;s/a/A/ is rejected as an invalid version, because the argument is read to the end of the line. GNU treats v as one command and then runs the substitute. The version should stop at ;, #, or }.
1v is rejected (command v expects up to 0 address(es)). GNU accepts addresses and still does nothing.
Version comparison is not a component-wise "no newer than 4.9". v3.99 and v4.8.99 are rejected even though they are older than 4.9. GNU sed 4.9 advertises two components, so v4.9 succeeds and v4.9.0 does not.
The command should stay a compile-time check and a no-op at runtime when the version is acceptable.
Activity