You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I start a command and then decide there's to much output and try and stop it with C-S, it doesn't stop. This works properly in most other shells.
Seems that fish purposely turns off flow control to make screen users with odd configurations happy. See issue #814: #814 for more info. I will say that being able to pause the output has nothing to do with vt100s, and everything to do with wanting to scroll through more output than your terminal emulator has lines configured.
My take is that the solution should be to make terminal_mode_for_executing_programs be set to the terminal mode after each command exits, rather than being whatever it was when the shell started with some random set of tweaks added. This would make stty work properly, so users could set it themselves.
Downside would be that if some command screws up the tty settings, it would propagate to future commands (but not suspended jobs). Just like it did back when I still used screen. But it also means that they can fix it with a simple "stty sane" (at least, they can on my Unix boxes).
See also issue #1041 which correctly points out another problem with the current approach to handling tty modes: A user can't change things like the character that generates a SIGINT.
I'll start reviewing the pull request associated with this issue. But before I do I want to make it clear that any change to fish's behavior needs to address multiple problems with the current implementation. Fish needs to not only honor changes to the tty modes made by stty when it runs a subsequent external command fish also needs to honor those changes when it becomes the foreground process. Consider the case noted in issue #1041 about not being able to change the interrupt key.
On the other hand, fish should protect itself, and future commands, against programs that exit without restoring the tty modes to sane values (or someone who uses the stty command to set non-sane modes). Fish should filter the current tty modes when it returns to the foreground by internally doing the equivalent of stty sane on the current tty modes.
I disagree about needing to "protect the user". You're assuming you know the users needs better than they do, which isn't particularly user friendly, and definitely limits expressiveness. That Unix gave users all the rope they wanted whether or not that was enough to hang themselves is a feature, not a bug.
Worse yet, you're risking making things that should be simple - let the user and their programs set the tty modes to whatever they feel they need when fish isn't in control - to incredibly complicated. "stty sane" may not be the right way to fix the thing that is wrong. What if some program is suspended by an external act with odd modes that it needs? Do you handle that case differently? Do you need to keep track of the tty mode set by every running program, and restore it properly when you foreground the program?
Other shells don't seem to generate multiple bugs around tty handling, probably because they don't take it upon themselves to keep the user from doing what they want.
Those other shells require the user to recognize that they need to type stty sane\cJ to restore the terminal to a sane mode that allows the use of the [enter] key for issuing commands to the shell. I'm a gray-beard. I've been programming since 1976 (on a Teletype Model 33 terminal) and using UNIX since the mid 1980's. Just because you and I are accustomed to dealing with this issue doesn't mean we should continue to inflict that pain on younger users.
Your other point regarding the handling of tty modes for programs suspended by a SIGSTOP signal (such as by the tty mode dsusp character, typically \cZ) is a good one. That definitely needs to be handled intelligently if fish is going to override tty modes. The question is whether fish can improve on the legacy shell experience in this regard. If fish cannot improve the experience without removing useful functionality then I agree with your implicit suggestion that fish stop trying to improve this situation.
The pull request as it exists is incomplete even given the very narrow scope of the initial problem statement. I'm okay with keeping the scope narrow and addressing the other problems I raised in a different issue. But only if the scope of this issue is increased to include a mechanism for ensuring the tty modes read in term_steal are sane. If we're going to propagate the modes as they exist when an external process exits we need to ensure they're sane for the next external command.
Not with the existing code. I submitted a pull request in #2317 that lets you turn them on and off with stty like any rational user expects. Not clear it works against the current build, because this fix is more important to me than anything that's gone into fish since, so I haven't bothered trying to update fish.
Flow control is a feature that's hard to love. Most uses are accidental (this is pretty popular!) and those keys could be better put to use elsewhere. Having flow control on by default is nuts.
Still it's very reasonable that fish should allow the user to modify the tty modes deliberately. But cat < nonsense.bin leading to busted ttys is a real issue too. I think our options are, from least to most permissive:
Stomp the tty modes always (current behavior)
Stomp the tty modes, except special case stty
Set the tty modes at startup, and try to sanitize them after every command
Set the tty modes at startup, but then leave them alone thereafter (bash-like behavior)
I recommend option 3 with an exception for the flow-control bit. That is, reset the tty modes to sane values after running an external command but retain the flow-control setting set by that command.
If the user explicitly reenables flow control by running stty ixon we should honor that. I'm not aware of any non-broken program which deliberately changes that setting. The primary question is whether we want to protect fish users against running a broken program which inadvertently changes the flow-control setting. Doing so would require special casing the stty command which bothers me.
It is not sufficient to remember termios changes made by external commands and use them only for subsequent external commands. If someone changes the interrupt character, for example, it should apply to the current fish shell not just subsequent external commands.
As for @mwm's SIGINFO example that would be handled by my proposal as they expect since it would preserve all "special characters" for the current interactive shell and subsequent external commands.
My recent testing of an unrelated problem on Cygwin and BSD left the non-fish shell unusable. Specifically, characters were not echoed and [enter] did not execute the command I typed. I had to run stty sane[ctrl-J] to restore my session to a usable state. Do we really want to require people to know how to deal with such situations?
You're right that fish ought to let users set a variety of tty features in shell mode as well. Please open another issue for it, though.
The current behavior of other shells is only relevant if they implement the proposed blacklist. As far as I know, none of them do that.
You're right, it's out of context: in that one, you're arguing that we shouldn't make it easy for users to protect themselves from a typo that results in executing "rm *", as opposed to taking away their ability to set the tty mode the way they want. I'm curious - if "stty sane' is to hard to expect users to remember it, what's the nice easy solution for 'rm *' that you expect them to use?
You haven't responded to my pointing out that we're not protecting the user from commands that set the terminal itself to some strange unusable state. For instance, try running "printf '\33(0\33)B" in your shell and tell me how usable it is.
I'd like to request some status update as well. I was brought here because stty intr <whatever> doesn't work in fish, and I'd love to see it working so that copy/paste shortcuts could be unified with the rest of the system.
Hi, would it be possible to implement anything to freeze screen output? I work with tools that write a lot of information to the screen. Sometimes need to scroll back in the log output of a tool to find a specific line. However, each time a new line is printed, the terminal jumps right back to the end. It is impossible to scroll back while a program is running under fish.
It does not really matter to me whether it is Ctrl-S/Q. It can be any weird key combination, just let me freeze the terminal. It is also OK to just make this a configurable option, where I must define my own key binding.
I love many things of the fish shell, and have switched exclusively to it, but this one issue is making fish unusable for me in one critical scenario.
I've had a recurring issue with fish for years, and my best guess is that it's related to this bug. When I SSH to other machines, the terminal settings get screwed up. The most noticeable symptom is that the Enter key no longer works properly inside the SSH session, instead sending a ^M. Running 'stty sane' in the SSH session resolves the issue, until the next time I connect to the server.
For example:
FWIW, I'm always running inside gnu screen, both my fish session on my local machine (a MacBook Pro running macOS) and on the remote server (running various versions of Linux).
Since the use case for flow control doesn't seem to be completely clear, I would like to be able to use flow control to stop fast-scrolling logs so I can read further up in the window about what's going on without further output scrolling the terminal all the way to the bottom.
Maybe this use case can be solved in urxvt, though. I've been thinking about (from an urxvt context) halting scrolling from perl, but now that I'm thinking about it and since the terminal emulator probably knows about whether flow control says "stop the flow", that a warning "flow is currently stopped" could be displayed (in reality, this means patching a high amount of terminal emulators though, unfortunately, if we care about a 100% solution). ^S/^Q have serious usability issues mostly because they're not visible and introduce random breakage for users who do not expect them, so I can see why there's reluctance in enabling them by default.
Yeah, I just changed it so we keep the terminal modes for external commands to whatever they were changed to. We didn't do any alterations before (we just kept what they were on startup), so I decided not to do so now.
That means if you want to enable flow control, use stty ixon ixoff and have fun.
The shell modes remain untouched, pristine, nice, usable modes. There's no stopping fish or enabling echo or anything, so if you break anything, use stty sane and press return - no need for ctrl-j shenanigans.
Alright, this was refined in #7133 to fixup modes that fish doesn't expect, many even for external commands - this includes stuff like OPOST, which needs to be on unless a program is explicitly made for it off, in which case it can just set it itself.
Then in #7704 we decided to copy ixon/ixoff into the shell's modes, so if you enable flow control it will also be enabled inside fish.
Activity
krader1961 commentedon Dec 25, 2015
See also issue #1041 which correctly points out another problem with the current approach to handling tty modes: A user can't change things like the character that generates a SIGINT.
krader1961 commentedon Dec 26, 2015
I'll start reviewing the pull request associated with this issue. But before I do I want to make it clear that any change to fish's behavior needs to address multiple problems with the current implementation. Fish needs to not only honor changes to the tty modes made by stty when it runs a subsequent external command fish also needs to honor those changes when it becomes the foreground process. Consider the case noted in issue #1041 about not being able to change the interrupt key.
On the other hand, fish should protect itself, and future commands, against programs that exit without restoring the tty modes to sane values (or someone who uses the stty command to set non-sane modes). Fish should filter the current tty modes when it returns to the foreground by internally doing the equivalent of
stty saneon the current tty modes.fpcomplete-support commentedon Dec 26, 2015
I disagree about needing to "protect the user". You're assuming you know the users needs better than they do, which isn't particularly user friendly, and definitely limits expressiveness. That Unix gave users all the rope they wanted whether or not that was enough to hang themselves is a feature, not a bug.
Worse yet, you're risking making things that should be simple - let the user and their programs set the tty modes to whatever they feel they need when fish isn't in control - to incredibly complicated. "stty sane" may not be the right way to fix the thing that is wrong. What if some program is suspended by an external act with odd modes that it needs? Do you handle that case differently? Do you need to keep track of the tty mode set by every running program, and restore it properly when you foreground the program?
Other shells don't seem to generate multiple bugs around tty handling, probably because they don't take it upon themselves to keep the user from doing what they want.
krader1961 commentedon Dec 26, 2015
Those other shells require the user to recognize that they need to type
stty sane\cJto restore the terminal to a sane mode that allows the use of the [enter] key for issuing commands to the shell. I'm a gray-beard. I've been programming since 1976 (on a Teletype Model 33 terminal) and using UNIX since the mid 1980's. Just because you and I are accustomed to dealing with this issue doesn't mean we should continue to inflict that pain on younger users.Your other point regarding the handling of tty modes for programs suspended by a SIGSTOP signal (such as by the tty mode dsusp character, typically \cZ) is a good one. That definitely needs to be handled intelligently if fish is going to override tty modes. The question is whether fish can improve on the legacy shell experience in this regard. If fish cannot improve the experience without removing useful functionality then I agree with your implicit suggestion that fish stop trying to improve this situation.
krader1961 commentedon Dec 27, 2015
The pull request as it exists is incomplete even given the very narrow scope of the initial problem statement. I'm okay with keeping the scope narrow and addressing the other problems I raised in a different issue. But only if the scope of this issue is increased to include a mechanism for ensuring the tty modes read in term_steal are sane. If we're going to propagate the modes as they exist when an external process exits we need to ensure they're sane for the next external command.
only swith to shell tty mode if interactive
trulyliu commentedon Dec 15, 2016
I need CTRL-S and CTRL-Q flow control feature.
Any way to bring it back?
mwm commentedon Dec 15, 2016
Not with the existing code. I submitted a pull request in #2317 that lets you turn them on and off with stty like any rational user expects. Not clear it works against the current build, because this fix is more important to me than anything that's gone into fish since, so I haven't bothered trying to update fish.
ridiculousfish commentedon Dec 15, 2016
Flow control is a feature that's hard to love. Most uses are accidental (this is pretty popular!) and those keys could be better put to use elsewhere. Having flow control on by default is nuts.
Still it's very reasonable that fish should allow the user to modify the tty modes deliberately. But
cat < nonsense.binleading to busted ttys is a real issue too. I think our options are, from least to most permissive:sttyI don't have any opinion yet - thoughts?
krader1961 commentedon Dec 15, 2016
I recommend option 3 with an exception for the flow-control bit. That is, reset the tty modes to sane values after running an external command but retain the flow-control setting set by that command.
If the user explicitly reenables flow control by running
stty ixonwe should honor that. I'm not aware of any non-broken program which deliberately changes that setting. The primary question is whether we want to protect fish users against running a broken program which inadvertently changes the flow-control setting. Doing so would require special casing thesttycommand which bothers me.31 remaining items
krader1961 commentedon Dec 26, 2016
It is not sufficient to remember termios changes made by external commands and use them only for subsequent external commands. If someone changes the interrupt character, for example, it should apply to the current fish shell not just subsequent external commands.
As for @mwm's SIGINFO example that would be handled by my proposal as they expect since it would preserve all "special characters" for the current interactive shell and subsequent external commands.
My recent testing of an unrelated problem on Cygwin and BSD left the non-fish shell unusable. Specifically, characters were not echoed and [enter] did not execute the command I typed. I had to run
stty sane[ctrl-J]to restore my session to a usable state. Do we really want to require people to know how to deal with such situations?Too, @mwm's use of my
quote is an example of using a quote out of context.
mwm commentedon Dec 26, 2016
You're right that fish ought to let users set a variety of tty features in shell mode as well. Please open another issue for it, though.
The current behavior of other shells is only relevant if they implement the proposed blacklist. As far as I know, none of them do that.
You're right, it's out of context: in that one, you're arguing that we shouldn't make it easy for users to protect themselves from a typo that results in executing "rm *", as opposed to taking away their ability to set the tty mode the way they want. I'm curious - if "stty sane' is to hard to expect users to remember it, what's the nice easy solution for 'rm *' that you expect them to use?
You haven't responded to my pointing out that we're not protecting the user from commands that set the terminal itself to some strange unusable state. For instance, try running "printf '\33(0\33)B" in your shell and tell me how usable it is.
dniku commentedon Aug 13, 2017
I'd like to request some status update as well. I was brought here because
stty intr <whatever>doesn't work in fish, and I'd love to see it working so that copy/paste shortcuts could be unified with the rest of the system.frankseide commentedon Feb 19, 2018
Hi, would it be possible to implement anything to freeze screen output? I work with tools that write a lot of information to the screen. Sometimes need to scroll back in the log output of a tool to find a specific line. However, each time a new line is printed, the terminal jumps right back to the end. It is impossible to scroll back while a program is running under fish.
It does not really matter to me whether it is Ctrl-S/Q. It can be any weird key combination, just let me freeze the terminal. It is also OK to just make this a configurable option, where I must define my own key binding.
I love many things of the fish shell, and have switched exclusively to it, but this one issue is making fish unusable for me in one critical scenario.
cowgod commentedon May 6, 2019
I've had a recurring issue with fish for years, and my best guess is that it's related to this bug. When I SSH to other machines, the terminal settings get screwed up. The most noticeable symptom is that the Enter key no longer works properly inside the SSH session, instead sending a ^M. Running 'stty sane' in the SSH session resolves the issue, until the next time I connect to the server.
For example:
FWIW, I'm always running inside gnu screen, both my fish session on my local machine (a MacBook Pro running macOS) and on the remote server (running various versions of Linux).
wilhelmy commentedon Mar 12, 2020
Since the use case for flow control doesn't seem to be completely clear, I would like to be able to use flow control to stop fast-scrolling logs so I can read further up in the window about what's going on without further output scrolling the terminal all the way to the bottom.
There's still no way to get it working?
frankseide commentedon Mar 12, 2020
I have the same use case as @wilhelmy.
wilhelmy commentedon Mar 19, 2020
Maybe this use case can be solved in urxvt, though. I've been thinking about (from an urxvt context) halting scrolling from perl, but now that I'm thinking about it and since the terminal emulator probably knows about whether flow control says "stop the flow", that a warning "flow is currently stopped" could be displayed (in reality, this means patching a high amount of terminal emulators though, unfortunately, if we care about a 100% solution). ^S/^Q have serious usability issues mostly because they're not visible and introduce random breakage for users who do not expect them, so I can see why there's reluctance in enabling them by default.
frankseide commentedon Mar 19, 2020
It would be great to even have this as a non-default option, something that power users can enable.
faho commentedon May 16, 2020
Yeah, I just changed it so we keep the terminal modes for external commands to whatever they were changed to. We didn't do any alterations before (we just kept what they were on startup), so I decided not to do so now.
That means if you want to enable flow control, use
stty ixon ixoffand have fun.The shell modes remain untouched, pristine, nice, usable modes. There's no stopping fish or enabling echo or anything, so if you break anything, use
stty saneand press return - no need for ctrl-j shenanigans.faho commentedon Feb 15, 2021
Alright, this was refined in #7133 to fixup modes that fish doesn't expect, many even for external commands - this includes stuff like OPOST, which needs to be on unless a program is explicitly made for it off, in which case it can just set it itself.
Then in #7704 we decided to copy ixon/ixoff into the shell's modes, so if you enable flow control it will also be enabled inside fish.