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

Turn terminal echo off on each source code execution by the interpreter #245

Closed
eldipa opened this issue May 28, 2022 · 0 comments · Fixed by #256
Closed

Turn terminal echo off on each source code execution by the interpreter #245

eldipa opened this issue May 28, 2022 · 0 comments · Fixed by #256
Labels
enhancement something nice to have but it is not neither critical nor urgent next-major For nonbackward compatible changes.
Milestone

Comments

@eldipa
Copy link
Collaborator

eldipa commented May 28, 2022

Describe the feature you'd like
byexample disables or turns off the echo of the terminal so any input is not echoed back and it is not being displayed on the "screen" which would get mixed the the interpreter's output.

This turn off happens at the moment that the runner/interpreter is spawned.

However some interpreters turn the echo on which makes byexample's efforts ineffective. This is the case of python on MacOS.
Other interpreters may implement their own terminal emulation which ignores the echo setting. This is the case of ipython and any program based on python-prompt-toolkit.

We cannot do anything with the latter but we can solve the issue in the former case.

We could call pexpect's setecho(False) before executing each source code, ensuring that the interpreter will not have a chance to turn it on again. We may call setecho(False) only once after the interpreter initialization if calling it before each source code exec is too slow.

Describe alternatives you've considered (optional)
An alternative could execute within the interpreter a shell and run there stty -echo but calling setecho(False) seems less hacky and faster.

Compatibility

For interpreters that honor the echo turned off during the spawn, calling setecho(False) should not change anything.

However for interpreters that don't honor and turn the echo on, calling setecho(False) may break user's examples.

Consider an user running byexample in MacOS. To make any sense of python's output mixed with the echoed code, the user probably is running byexample with +force-echo-filtering. This unfortunately requires that the interpreter is really echoing the code. If we "fix" the issue calling setecho(False), we'll make python to not echo the code on MacOS (good) but it will break any user running +force-echo-filtering because now, no echo has to be filtered!

It would be tempting to say "if the echo was successfully turned off, ignore +force-echo-filtering" but this does not work.

  1. +force-echo-filtering implies +term=ansi so this heavily changes the way that the output is processed. Ignoring +force-echo-filtering will break the examples too.
  2. some interpreters emulate a terminal and they will totally ignore the echo setting even if the echo is turned off so +force-echo-filtering still has value.

Probably the safest thing to do is to say "if +force-echo-filtering is on, do not call setecho(False)" and update the documentation for MacOS users that they can try byexample 11.0.0 without setting +force-echo-filtering.

@eldipa eldipa added the enhancement something nice to have but it is not neither critical nor urgent label May 28, 2022
@eldipa eldipa added this to the 11.0.0 milestone May 28, 2022
@eldipa eldipa added the next-major For nonbackward compatible changes. label May 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement something nice to have but it is not neither critical nor urgent next-major For nonbackward compatible changes.
Projects
None yet
1 participant