Repository navigation
interpreter: keep the earlier exit status on a bare exit in END - #190
Conversation
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.
|
GNU awk testsuite comparison: |
| CtrlSig::NextFile => break, // clean-up & read next file | ||
| CtrlSig::Exit(code) => return self.end_event_loop(code).map(|_| ()), | ||
| CtrlSig::Exit(code) => { | ||
| return self.end_event_loop(code.unwrap_or(0)).map(|_| ()); |
There was a problem hiding this comment.
unwrap_or(0) is now repeated 4 times. Could end_event_loop take the Option<i32> and do end_code.or(code).unwrap_or(0) itself?
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.
|
Thanks for the review. Done in e9bf24d: One note: I do not have a Rust toolchain on this machine, so I have not compiled or run this follow-up locally. I checked the types and the other call sites by reading the code, so I am relying on CI here. If it fails I will fix it right away. |
|
GNU awk testsuite comparison: |
A bare `exit` always exited with 0. Lower it to its own instruction and signal so that, in END, the status of an earlier exit is kept as POSIX requires.
e9bf24d to
ca27c53
Compare
|
Done, thanks: it is back to one line and I rebased onto main (the old conflict was in main_event_loop). |
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.
|
GNU awk testsuite comparison: |
Alonely0
left a comment
There was a problem hiding this comment.
I'm sorry, so inheritance just for exit codes? That was not in my AWK dark corner bingo card. anyway, thank you very much for the fix!! merging this now :)
Fixes #182
BEGIN { exit 3 } END { exit }exited with 0 because a bareexitwas lowered toexit 0. POSIX says that in END it keeps the status of an earlierexit.How
A bare
exitis now its own instruction (ExitKeep) andCtrlSig::Exitcarries anOption<i32>.end_event_loopuses the status it was called with when END ends with a bareexit; everywhere else a bareexitstill means status 0 as before.Tests
bare_exit_in_end_keeps_status: the case from the issue plusBEGIN { exit 3 } END { exit },BEGIN { exit 3 } END { exit 4 }(explicit status still wins) and a bare exit in both (0).cargo test --workspacepasses,cargo clippy --workspace --all-targets -- -D warningsandcargo fmt --all --checkare clean.