In the first case, the command modifies the tty state and the state is
kept for the following commands.

In the second case, the command that modifies the tty state is
interrupted, then when restarted the tty state is restored for it but
when it finishes the tty state is reset to the default again, which is
not consistent with the first case.

Is this a bug as I think it is?

``` 1
$ stty intr ^C; stty; sh -c 'stty intr ^G; sleep 2; stty'; stty                 
                                          
speed 38400 baud; line = 0;
-brkint -imaxbel iutf8
speed 38400 baud; line = 0;
intr = ^G;
-brkint -imaxbel iutf8
speed 38400 baud; line = 0;
intr = ^G;
-brkint -imaxbel iutf8
```

``` 2
$ stty intr ^C; stty; sh -c 'stty intr ^G; sleep 2; stty'; stty                 
                                          
speed 38400 baud; line = 0;
-brkint -imaxbel iutf8
^Zspeed 38400 baud; line = 0;
-brkint -imaxbel iutf8
[1] + Stopped              \sh -c "stty intr ^G; sleep 2; stty" 
$ fg; stty                                                                      
                                          
\sh -c "stty intr ^G; sleep 2; stty" 
speed 38400 baud; line = 0;
intr = ^G;
-brkint -imaxbel iutf8
speed 38400 baud; line = 0;
-brkint -imaxbel iutf8
```

PS. ksh saves the tty state when a job is stopped, restored it when it
is restarted, and keeps the modified state when the job finishes.  bash
resets a default when a job is stopped but does not save the tty state
it seems.

Reply via email to