Skip to content

expand: avoid panics on division by zero#934

Merged
mvdan merged 1 commit intomasterfrom
892-div-zero
Oct 21, 2022
Merged

expand: avoid panics on division by zero#934
mvdan merged 1 commit intomasterfrom
892-div-zero

Conversation

@mvdan
Copy link
Owner

@mvdan mvdan commented Oct 20, 2022

(see commit message)

Fixes #892.

@mvdan
Copy link
Owner Author

mvdan commented Oct 20, 2022

cc @dankegel

Copy link
Contributor

@theclapp theclapp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. Found some more panics with %, though.

Arithm now returns one more type of error for this case.
Update the interpreter accordingly, and add tests.

The behavior we adopt follows what Bash does when not run interactively,
so start documenting that in the package godoc.

Also add a TODO as we should have some standard to tell whether errors
coming from the expand package or the user's handlers are fatal.
That is, whether they should exit the shell, and with what status code.

While here, replace black and white with block and allow,
which are more self-explanatory.

Fixes #892.
@mvdan
Copy link
Owner Author

mvdan commented Oct 21, 2022

Thanks for the great review, @theclapp. I'll probably bother you for more interpreter reviews, if that's okay :)

@mvdan
Copy link
Owner Author

mvdan commented Oct 21, 2022

Got a weird failure on Mac I haven't seen before. Maybe the machine crashed somehow.

@mvdan
Copy link
Owner Author

mvdan commented Oct 21, 2022

I'm perplexed at the repeated macos failure. It happens on pull_request but not on push, which should be the same code. And master passed. And the failure is in the shfmt tests, where it depends on neither of the packages modified here. I'll rerun all the jobs and see...

@mvdan
Copy link
Owner Author

mvdan commented Oct 21, 2022

Green, so I will ignore that. For the record, they were signal: killed errors in the cmd/shfmt test scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

interp: panic on division by zero

3 participants