[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A question about the INTR char
From: |
Dennis Clarke |
Subject: |
Re: A question about the INTR char |
Date: |
Sat, 1 Feb 2025 09:44:01 -0500 |
User-agent: |
Mozilla Thunderbird |
On 1/23/25 18:38, Thomas Dickey wrote:
On Tue, Jan 21, 2025 at 08:25:03PM -0500, Dennis Clarke wrote:
Firstly : I apologize for quoting content from an email titled "CTRL-L
Clear Screen" from sometime last year. I have been pouring over the man
pages for stty trying to figure out something that should be trivial.
However it seems to escape me. No pun intended. This is not a bug in
anything other than strange behavior I am seeing on FreeBSD.
On 6/23/24 05:25, Thomas Dickey wrote:
On Sun, Jun 23, 2024 at 03:19:57AM -0400, Steve Litt wrote:
Thomas Dickey said on Sat, 22 Jun 2024 17:19:54 -0400
On Fri, Jun 21, 2024 at 07:01:44AM +1000, Michael D. Setzer II wrote:
Just wondering if the Ctrl-L would clean screen?
A few terminals (mostly emulators actually) will clear the screen on
^L. DEC's hardware terminals were not among those; xterm likewise.
I don't know if this is relevant to this discussion, but when I
.
. < snip some great stuff from long ago when we had paper terminals >
.
.
Terminal emulators can of course have lots of sizes, and it's been that
way a while. This one dates back to the 1980s:
x10term|vs100-x10|xterm terminal emulator (X10 window system),
OTbs, am, km, mir, msgr, xenl, xon,
cols#80, it#8, lines#65,
The Bitgraph terminal that I used in 1983-1984 had 65 lines.
Fairly certain I was sitting in front of some DECwriter type paper
terminal back in those days. Within the next year there were glass
CRT type terminals available all around me. Mostly DEC VT100 units
and some with APL style terminal keyboards. Those were just greek
to me however.
When I used it to develop a font editor, I asked one of the people
in my department how I could use termcap to represent its graphical
escape sequences. He told me that termcap didn't do stuff like that.
https://invisible-island.net/personal/oldprogs.html#y1984
I will have to go digging around in there and see what there is. I think
that FORTRAN and Pascal were the popular languages at the time. However
the new "C" was sneaking in seemingly everywhere.
bold=\E[1m, clear=\E[H\E[2J, csr=\E[%i%p1%d;%p2%dr,
cub1=^H, cud1=\n, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P, ed=\E[J, el=\E[K,
home=\E[H, ht=^I, ind=\n, is2=\E\E[m\E[?7h\E[?1;4l, kbs=^H,
kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kf1=\EOP,
kf2=\EOQ, kf3=\EOR, kf4=\EOS, rev=\E[7m, ri=\EM, rmam=\E[?7l,
rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[m, rmul=\E[m,
sgr0=\E[m, smam=\E[?7h, smir=\E[4h, smkx=\E[?1h\E=,
smso=\E[7m, smul=\E[4m, use=ansi+idl,
Here is where I need to ask why a terminal would display the chars "^C"
when a user hits the INTR key sequence as described in the stty settings
at the time? Here is an example from an old Solaris server :
hubble $ uname -a
SunOS hubble 5.10 Generic_150400-67 sun4u sparc SUNW,SPARC-Enterprise
hubble $
hubble $ stty -a
speed 38400 baud;
rows = 32; columns = 96; ypixels = 776; xpixels = 1175;
csdata ?
eucw 1:0:0:0, scrw 1:0:0:0
intr = ^c; quit = ^\; erase = ^?; kill = ^u;
eof = ^d; eol = -^?; eol2 = -^?; swtch = <undef>;
start = ^q; stop = ^s; susp = ^z; dsusp = ^y;
rprnt = ^r; flush = ^o; werase = ^w; lnext = ^v;
-parenb -parodd cs8 -cstopb -hupcl cread -clocal -loblk crtscts -crtsxoff
-parext
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl -iuclc
ixon -ixany -ixoff -imaxbel
isig icanon -xcase echo echoe echok -echonl -noflsh
-tostop echoctl -echoprt echoke -defecho -flusho -pendin iexten
opost -olcuc onlcr -ocrnl -onocr -onlret -ofill -ofdel tab3
hubble $
hubble $ ls -la /var/^C
hubble $
There you see that I began to type the command "ls -la /var/" and then hit
the CTRL - c sequence. Here I am careful to say lowercase "c" but I can tell
you that holding the SHIFT key and then CTRL - C uppercase works the same.
Above we see that "intr = ^c" and so this all makes perfect sense.
control-C is "just" the low-order 5 bits of the character.
c = 0x63
C = 0x43
A ha ... that makes sense. There was a time where we only had uppercase
chars on the terminal keyboard and if my memory serves me then I recall
that one would LOGIN with such a terminal and everything was uppercase.
This was not seen as much of a problem for FORTRAN work.
(it doesn't make sense to people on StackOverflow who assume that every
character comes along with a list of modifiers).
On just about any recent FreeBSD machine I can not see the CTRL-c chars at
all. They simply do not appear :
I recall seeing some recent (month or two ago) comment on this,
with someone asking if it was an intentional change (and -- from memory)
that it was not intentional.
It really does seem like a bug and quite annoying behavior.
So I have to wonder if this is a shell problem with /bin/sh on all
recent FreeBSD versions or simply a nifty terminal config?
It seems like a bug to me :-)
I connected a LINK MC5 type serial terminal to a FreeBSD 14.2-RELEASE
machine and that will remove any questions about network access from the
situation. Then I set the baud rate to 1200 for ispeed/ospeed and it
works just fine. Sure enough, the default bourne shell in FreeBSD just
refuses to display the "^C" chars when I hit CTRL-C. In fact, that shell
seems to wreck the state of the echoctl flag.
I will likely write an unpopular bug report on this today.
Well at least the baud rate changed but the INTR char sequence is invisible.
Is there a way to manage this with stty/terminal config?
probably not
Well actually I can set the echoctl flag ON and OFF but this only works
if I build my own shell from sources. Which I did just to demonstrate
the point. I used a very limited bash shell config :
$
$ uname -apKU
FreeBSD hydra 14.2-RELEASE FreeBSD 14.2-RELEASE
releng/14.2-n269506-c8918d6c7412 GENERIC amd64 amd64 1402000 1402000
$
$ echo $SHELL
/home/dclarke/local/bin/bash
$
$ $SHELL --version
GNU bash, version 5.2.37(2)-release (x86_64-unknown-freebsd14.2)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$
Here I am logging in via a serial connection :
$ who | grep 'dclarke'
dclarke ttyu0 Jan 30 21:55
$
$ grep 'ttyu0' /etc/ttys
ttyu0 "/usr/libexec/getty 3wire.1200" vt100 on secure
$
$ stty -a
speed 1200 baud; 24 rows; 80 columns;
lflags: icanon isig iexten echo echoe -echok echoke -echonl echoctl
-echoprt -altwerase -noflsh -tostop -flusho -pendin -nokerninfo
-extproc
iflags: -istrip icrnl -inlcr -igncr ixon -ixoff ixany imaxbel -ignbrk
brkint -inpck -ignpar -parmrk iutf8
oflags: opost onlcr -ocrnl tab3 -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl clocal -cstopb -crtscts -dsrflow
-dtrflow -mdmbuf rtsdtr
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
eol2 = <undef>; erase = ^?; erase2 = ^H; intr = ^C; kill = ^U;
lnext = ^V; min = 1; quit = ^\; reprint = ^R; start = ^Q;
status = ^T; stop = ^S; susp = ^Z; time = 0; werase = ^W;
$
My very limited bash shell has no support for line editing nor any
handling of control char sequences such as the arrow keys on the
keyboard. In fact, there is as close to nothing supported as one can
get these days :
$ readelf -delV /home/dclarke/local/bin/bash | grep 'NEEDED'
0x0000000000000001 NEEDED Shared library: [libintl.so.8]
0x0000000000000001 NEEDED Shared library: [libiconv.so.2]
0x0000000000000001 NEEDED Shared library: [libdl.so.1]
0x0000000000000001 NEEDED Shared library: [libc.so.7]
$
However this limited bash shell respects the echoctl flag. Since I have
the tty set to 1200 baud I can hit CTRL-C while output is being sent :
$
$ ls -lap $HOME
total 11044
drwxr-x--- 10 dclarke dclarke 32 Jan 30 00:16 ./
drwxr-xr-x 12 root dev^Ccshrc
$
Nothing the "^C" there? That is correct behavior.
$
$ stty -echoctl
$ ls -lap $HOME
total 11044
drwxr-x--- 10 dclarke dclarke 32 Jan 30 00:16 ./
drwxr-xr-x 12 root devl 12 Nov 19 20:22 ../
-rw------- 1 dclarke dclarke 102 Jan 30 00:16 .Xauthority
-rwx------ 1cshrc
$
$ ls -lapb $HOME
$
No one can see that I did hit CTRL-C twice. There is no echo of the ctrl
chars to the terminal. This is correct with -echoctl.
$ stty echoctl
$ ls -lapb $HOME ^C
$
Trivial to enable echoctl.
That process does not work at all with the FreeBSD default bourne shell.
--
--
Dennis Clarke
RISC-V/SPARC/PPC/ARM/CISC
UNIX and Linux spoken
- Re: A question about the INTR char,
Dennis Clarke <=