bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fg via keybind modifies tty settings


From: David Moberg
Subject: Re: fg via keybind modifies tty settings
Date: Sat, 12 Oct 2024 07:11:29 +0200

Has anyone been able to take a more deep look? Where in the bash source
code would this happen?

I learned that fish resets these kind of settings quite often.

Den tis 24 sep. 2024 16:21Chet Ramey <chet.ramey@case.edu> skrev:

> On 9/20/24 7:23 PM, David Moberg wrote:
>
> > Bash Version: 5.2
> > Patch Level: 21
> > Release Status: release
> >
> > Description:
> >          When a process/job is suspended, foregrounded via ctrl-a as a
> > keybinding for fg, and then
> >          suspended again, the tty will be in a surprising state where no
> > input is seen (-echo)
>
> When the shell starts a job with `fg', it fetches the tty settings so it
> can restore them if the job exits or stops due to a signal. That way, a
> job that modifies the terminal settings, then crashes, doesn't leave the
> terminal in an unusable state.
>
> When you run a command from a readline key binding, it still runs in the
> context of readline obtaining a line from the keyboard -- it's just another
> key binding, like C-f. Readline doesn't reset the tty settings to run the
> binding, and bash doesn't reset them to run the command.
>
> When `fg' runs and starts the job, the shell fetches the tty settings as
> usual, but they are the tty settings readline uses when it's reading input.
> It assumes those are the `normal' settings.
>
> When vim stops due to the SIGTSTP, the shell restores what it thinks are
> the normal tty settings -- the ones it fetched after readline modified
> them. The difference you see between the `working' and `broken' settings
> is what readline does so it can read input.
>
> I will see if this can be changed by having `fg' detect whether it's
> being run from a key binding and not fetch the terminal settings in that
> case.
>
> Chet
>
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>                  ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]