On Wed, 13 Nov 2024 at 01:49, Chet Ramey <chet.ra...@case.edu> wrote:
> On 11/10/24 7:14 PM, Martin D Kealey wrote: > > > Perhaps what's really needed is to make sure that "ordinary" commands > bound > > using bash -x are completely broken (so people won't try to use them), > > rather than almost working. > > `Ordinary' commands aren't broken. Programs like vim that modify the > terminal settings, which are in the minority, are. > Fixing things for 'vim', will likely break them for me. That's why I'm suggesting that there needs to be two separate ways of "binding an invocable command". For many commands it won't matter which one you use, but for I have a use case where I do NOT want the stty settings to be restored after running a command from a key binding, because it would defeat the point: bind -x '"\C-_": stty tostop' This enables me to hit ctrl-7 (same key as '&') to temporarily turn on TOSTOP in termios.c_lflags, to prevent the output of a background command from messing up the line I'm currently editing (and vice versa). (The choice of key or escape sequence isn't important; it's the effect of stty that matters.) Currently it only lasts as long as it takes me to type the current command, which is useful but not critical. Here's an example transcript; please take note of the timestamps in the prompt: > 11:47:44 3$ bind -x '"\C-_": stty tostop' > 11:48:02 4$ stty -a | grep -o .tostop > -tostop > 11:51:11 5$ (sleep 5 ; echo Hello)& > [1] 21951 > 11:51:25 6$ echo Hi* # at this point I hit ctrl-7 and then wait a while > before hitting enter; note the absence of intermingling* > Hi > > [1]+ Stopped ( sleep 5; echo Hello ) > 11:51:35 7$ bg > [1]+ ( sleep 5; echo Hello ) & > Hello > [1]+ Done ( sleep 5; echo Hello ) > 11:51:38 8$ stty -a | grep -o .tostop > -tostop > -Martin