Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os: Add exception_on_failure to os:cmd/2 #9082

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

garazdawi
Copy link
Contributor

exception_on_failure makes os:cmd/2 fail when the command exits with a failure reason. Before this change the user had to check the output from the command to know if it failed or not, now an exception will be thrown instead.

I decided to not implement it as a different return value as that would change the return signature of os:cmd/2 depending on which options are passed which makes it a lot more difficult for static analysis tools to know what this function can return.

I'm not very happy with this new API, so if anyone has any better ideas on how this should work please suggest them!

exception_on_failure make os:cmd/2 fail when the command
exits with a failure reason. Before this change the user
had to check the output from the command to know if it
failed or not, now an exception will be thrown instead.

I decided to not implement it as a different return value
as that would change the return signature of os:cmd/2 depending
on which options are passed which makes it a lot more
difficult for static analysis tools to know what this
function can return.
@garazdawi garazdawi added the team:VM Assigned to OTP team VM label Nov 18, 2024
@garazdawi garazdawi added this to the OTP-28.0 milestone Nov 18, 2024
@garazdawi garazdawi self-assigned this Nov 18, 2024
Copy link
Contributor

github-actions bot commented Nov 18, 2024

CT Test Results

    2 files     70 suites   1h 7m 52s ⏱️
1 564 tests 1 322 ✅ 242 💤 0 ❌
1 814 runs  1 522 ✅ 292 💤 0 ❌

Results for commit f06ef64.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@u3s u3s self-requested a review November 18, 2024 16:35
Copy link
Contributor

@u3s u3s left a comment

Choose a reason for hiding this comment

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

I've no better idea for that change.
Having different function with ok/error tuple would be nicer of course but maybe not worth it.

@garazdawi garazdawi added the testing currently being tested, tag is used by OTP internal CI label Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team:VM Assigned to OTP team VM testing currently being tested, tag is used by OTP internal CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants