Skip to content

Add support for use_stdio option to System.shell and Mix.Shell.cmd #13580

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

Merged
merged 2 commits into from
May 24, 2024

Conversation

saveman71
Copy link
Contributor

See #13531

@@ -1179,6 +1183,11 @@ defmodule System do
defp cmd_opts([{:stderr_to_stdout, false} | t], opts, into, line),
do: cmd_opts(t, opts, into, line)

defp cmd_opts([{:use_stdio, false} | t], opts, into, line) do
opts = opts -- [:use_stdio, :stderr_to_stdout]
Copy link
Member

Choose a reason for hiding this comment

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

We cannot remove stderr_to_stdout after because there is no guarantee it was set before. For example, someone can do use_stdio: false, stderr_to_stdout: true and now it won't be removed. We should also support use_stdio: true and we can add a test for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've come up with something. However not very happy with the tests - they're on unix only for one - but obviously detaching the IO means we don't capture it anymore so it logs a bit on the console.

Copy link
Contributor Author

@saveman71 saveman71 May 21, 2024

Choose a reason for hiding this comment

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

(note about the use_stdio: false, stderr_to_stdout: true case, we could just forward that to erlang and it'll raise, even though I added an extra check at the end for that to log our own message)

     expected:
       ~r/cannot use `stderr_to_stdout: true` and `use_stdio: false`/
     actual:
       "errors were found at the given arguments:\n\n  * 2nd argument: invalid option in list\n"

arguably it's less clear though

@josevalim josevalim merged commit 9651afa into elixir-lang:main May 24, 2024
9 checks passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

@saveman71 saveman71 deleted the add_use_stdio branch May 24, 2024 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants