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

Allow flow control also in the shell #7708

Merged
merged 6 commits into from
Feb 15, 2021
Merged

Conversation

faho
Copy link
Member

@faho faho commented Feb 11, 2021

Description

This specifically copies IXON/IXOFF from the terminal modes after a command to the shell-modes, so you can use

stty ixon ixoff

to enable flow control (and stty -ixon -ixoff to disable it again). This brings with it the obvious issues that you lose two keychords (ctrl-s and ctrl-q by default, typically) and that it might be confusing if you're not familiar with it (unless your terminal tells you what happened, like e.g. konsole does).

It's technically possible someone ends up with flow control enabled accidentally - this doesn't check if the command was stty after all - but I'm assuming that's highly unlikely, and even if it did the shell would still basically work.

It also still disables flow control on startup so you specifically have to ask for it - we don't want to give up ctrl-s.

Fixes issue #7704.

TODOs:

  • Changes to fish usage are reflected in user documentation/manpages.
  • Tests have been added for regressions fixed
  • User-visible changes noted in CHANGELOG.rst

Not sure how to test this - can we just send ctrl-s from pexpect? How do we then know it worked? Confirm that no output happened? Does this require waiting for a timeout?

@depau
Copy link

depau commented Feb 11, 2021

Not sure how to test this - can we just send ctrl-s from pexpect? How do we then know it worked? Confirm that no output happened? Does this require waiting for a timeout?

(I'm not familiar with how fish tests work) FWIW if you can run tty from inside fish and record the pts path, you can then run stty -a -F /dev/pts/# externally and verify whether the terminal mode is correct. Even easier if pexpect allows you to retrieve the pty slave name.

This will work on Linux for sure, I don't know about macOS.

@depau
Copy link

depau commented Feb 11, 2021

I confirm that the latest changes address my comment #7704 (comment)

Thanks :)

src/builtin_bind.cpp Outdated Show resolved Hide resolved
@faho faho force-pushed the flow-control-2 branch 3 times, most recently from dd4e399 to 995f90f Compare February 12, 2021 18:54
Since, unlike e.g. OPOST, this can sometimes be useful, just copy
whatever flow control settings the terminal ends up with.

We still *default* flow control to off (because it's an awful default
and allows us to bind ctrl-s), but if the user decides to enable it so
be it.

Note that it's _possible_ flow control ends up enabled accidentally, I
doubt this happens much and it won't render the shell unusable (and
good terminals might even tell you you've stopped the app).

Fixes fish-shell#7704
Without flow control enabled these won't be interpreted any way.
We actually restore those before exit, so this would force-disable
flow control whenever fish exits.
I have no idea how to see that flow control has worked otherwise
This is a bit of an interesting pexpect test, but honestly pexpect
works quite well! I'm happy with it!
This fails on FreeBSD on sr.ht and NetBSD on my own VM, but it works manually.

It also fails on macOS but I have no way to confirm.

I think it might be a problem in pexpect's platform support?

Either way, the test is valuable so just skip it there and solve it later.
@faho faho merged commit ca4836f into fish-shell:master Feb 15, 2021
@faho faho deleted the flow-control-2 branch July 29, 2021 15:57
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants