16 ms·
Why does the `reset` command include a delay? (2017)
- fuzztester 3y agoBack in the day, when the screen/terminal was borked, due to catting a binary or other reasons, we used to do; stty sane Ctrl-J or other variants. It mostly worked. Last resort was to switch the terminal off and on, and/or to kill the login shell from another terminal, IIRC. See: man stty
- oefrha 3y agoBack in the day? What’s the modern way to do it if not stty sane?
- fuzztester 3y agoDonno. Haven't had the issue for long now, so donno.
- khaki54 3y agoHe doesn't know because he learned his lesson and stopped trying to cat binaries all the time haha
- fuzztester 3y agoBad guess, ho ho. Others catted binaries, I knew not to. I cut my teeth (pun intended) on Unix (pre-Linux) very early in my career.
- fuzztester 3y agoAlso, buzz off, troll. Have you ever done anything constructive and positive in your life, or do you just fart around trying to get cheap thrills and boost your ego by trying to make fun of others? Check out "The Man in The Arena" and get enlightened. https://en.m.wikipedia.org/wiki/Citizenship_in_a_Republic https://en.m.wikipedia.org/wiki/Citizenship_in_a_Republic Relevant excerpt: [ Citizenship in a Republic is the title of a speech given by Theodore Roosevelt, former President of the United States, at the Sorbonne in Paris, France, on April 23, 1910.[1] One notable passage from the speech is referred to as "The Man in the Arena":[2][3] It is not the critic who counts; not the man who points out how the strong man stumbles, or where the doer of deeds could have done them better. The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood; who strives valiantly; who errs, who comes short again and again, because there is no effort without error and shortcoming; but who does actually strive to do the deeds; who knows great enthusiasms, the great devotions; who spends himself in a worthy cause; who at the best knows in the end the triumph of high achievement, and who at the worst, if he fails, at least fails while daring greatly, so that his place shall never be with those cold and timid souls who neither know victory nor defeat. Someone who is heavily involved in a situation that requires courage, skill, or tenacity, as opposed to someone sitting on the sidelines and watching, is often referred to as "the man in the arena". ] https://en.m.wikipedia.org/wiki/Theodore_Roosevelt https://en.m.wikipedia.org/wiki/Theodore_Roosevelt
- aumerle 3y agoTo workaround it add the following to your shell's rc file: function reset { printf '\e]\e\\\ec' } Uses the VT100 RIS escape code to ask the terminal to reset itself. But first it send an empty OSC escape to reset the terminals VT parser back to normal mode, so that the RIS escape code is parsed correctly. No need to depend on any external utilities like tput or the reset binary. This should work with any halfway decent terminal emulator.
- deleted 3y ago[deleted]
- DeathArrow 3y ago>Real (hardware) terminals need that. I wonder who uses real terminals and for what.
- dataflow 3y ago> I wonder who uses real terminals and for what. I'm guessing the same people who believed 1991 was the year of Linux on the desktop.
- ssl-3 3y agoI used to have some real (hardware) terminals, back in the day when (what we then called) IP Masquerading was still kind of new, Ethernet was still expensive to sensibly implement, and old cheap still-useful PC hardware didn't usually exist (and things like freebie "closet laptops" absolutely did not exist at all). It was a bit of a different world back then. Most of my Internet and general-computing experience happened in a terminal -- whether xterm, 80x25, or a silly high-res BIOS-based text mode set using svgatextmode. Text-based web browsing with Lynx was still useful, and Pine (email) and tin (usenet) were well-suited to those applications at that time. I had a desktop Linux (or sometimes, FreeBSD) box that I of course did all kinds of stuff with, and at least one remote shell account on a far-away computer to provide continuity, and I also had a couple of DEC VT330 terminals that I scored cheap at the Dayton hamfest. One was next to my favorite armchair so I could chat on IRC and listen to the stereo in the sweet spot at the same time. Another was in the bedroom, which I mostly used for reading books and other passive consumption. It all worked well, of course. There was no reason for it not to work well. And at a time when the Internet was kind of a weird thing to be involved with at all, and almost always involved exactly one person using one dialup connection in exactly one physical location, I could meander around and do my usual Internet things in a few different locations in the house (thanks, screen!). I didn't really build it for multiple users. But sometimes, the girlfriend would hang out and chat on IRC in one place while I did my own Internet things elsewhere, all on a light-weight 32-bit computer with only a few megabytes of RAM. It did fine. --- But your question was present-tense. Because life has a way of things, I've sadly lost track of those VT330s. And your implication is correct: I haven't seen a standalone terminal in the wild for a really, really long time. In the present-tense, I kind of miss the expediency of the interface. Many of us here use terminal emulators every day, so it may sound like I'm preaching to the choir, but I mean: The expedience of the text-based interfaces out in the wild. It is seemingly as lost as my VT330s are. It used to be that if I needed a set of spark plugs for a car, then I might pop over to Autozone. The guy behind the counter there would mash in the make/model/year almost instantly on the terminal's keyboard, as if by muscle memory, and almost immediately he'd be rattling off different options, prices, and features. Nowadays it's all web based. The parts store clerk's stupid-fast muscle memory has been replaced by mousing around interactively -- clicking and drooling (and worse: scrolling through stupid HTML dropdowns to find "Toyota," or "Volvo") through a website that is very much like the same website I can use from home. And that website sucks, time-wise, compared to the dumb terminal interface that they used to have muxed back to the home base. (The only advantage I can find to the web interface that has been in place for a quarter of a century now is that it has pictures, but the pictures are often simply wrong. Bad data is no data, so this is a misfeature.)
- dataflow 3y agoI love the "It's harmless with a terminal emulator". I (obviously) get what they're saying, but you'd think making millions of people waste 3 seconds of their lives every time would be considered at least a modicum of harm.
- draw_down 3y ago[dead]
- hnlmorg 3y agoThat’s a touch exaggerative don’t you think? reset wouldn’t be used used by millions of people and most of those who do use wouldn’t be using it regularly either. reset should be a last resort. If you need to use it then something else has gone wrong and thats what needs to be fixed. I’m all for modernising our terminal but in this instance we are talking about a last resort command taking 3 seconds longer than needed just in case some of some edge case scenario occurs. So 3 seconds is definitely not harmful.
- ryandrake 3y agoI think in this case it's a bit exaggerative, but this isn't the only example--the mentality is pervasive throughout software engineering: It's OK to sacrifice the user's time (through poor software performance, unnecessary network calls, mutexes and synchronization, and deliberate delays) for developer comfort, or if it means we can go fix something else, or if it's just a really hard problem... Hey, user's time doesn't cost us and they can always wait... And it adds up: 100ms here, 200ms there, times millions of users, times dozens of times per day the issue happens, and it's no wonder our 2024-era supercomputers still feel about as slow as my 2004 Windows XP machine.
- hnlmorg 3y agoI completely agree. But in this case ‘reset’ isn’t the problem. It’s that terminal emulators don’t surface an easier and more standardised way to clear their scrollback history. That’s the thing that needs fixing.
- charcircuit 3y ago>and since there's no conventional way to tell the difference (and too hard to determine if some escape sequence might do a hardware-reset), reset assumes your terminal is real. The TERM environmental variable can be used
- phone8675309 3y agoSure, okay, but there's two problems with that: 1) you have to trust the user to get that right, and 2) how do you know it's an actual hardware terminal and not a terminal emulator?
- leni536 3y agoTERM is already used for determining color support. Not sure what terminals do without color support with color escape codes.
- hnlmorg 3y ago> TERM is already used for determining color support. It's one of many ways to determine colour support. And arguably the worst of all of the ways too. - $TERM This isn't intended to contain colour information, yet that's how it's often abused. Meaning a lot of applications are broken in non-xterm terminals if they happen to use the $TERM variable correctly - ANSI code: CSI 22 c (Send Device Attributes, ANSI color) This is the correct way to check for a device capability. But it requires more effort and knowledge of terminals than your average developer has. So is rarely supported by console applications. - $COLORTERM This is the modern day equivalent to the device capability API. But also isn't used often - $COLORFGBG This was the original env var intended to be used like $COLORTERM, but fell out of favour because, well, nobody bothered to read any docs. - $FORCE_COLOR This is an often used standard. Christ only knows why this one exists when we already have 3 other env vars being used this way. Another example of nobody bothering to read any docs - $NO_COLOR This is intended to do the opposite of the others and tell applications not to use colour. However even this is often ignored. ---- That's 6 different ways to check whether to colour output or not. Only one actual standard method and everything is only partially supported (if at all) in applications. Hence why applications then need a `--color` flag, which even that differs in support and syntax across different command line tools. And the "default" method you described, $TERM, actually breaks applications on alternative terminal emulators and hardware terminals -- that is unless they decide to announce themselves as `xterm` and in that case that environmental variable becomes entirely pointless because it has naff all to do with terminal listening. ---- > Not sure what terminals do without color support with color escape codes. They ignore them. ANSI escape codes are a pain in the arse to parse but there is at least a documented standard way to parse them. Anything that is a CSI (Control Sequence Introducer) sequence, and that includes SGR (Select Graphic Rendition) parameters like colour codes, start with `{ESC}[` and terminate with a character in the range of 0x40 to 0x7E. It's actually a little more complicated than that[1] but that's the gist of it. So you know what to print and what to ignore. There are other escape sequences too, the other big one being OSC (Operating System Command) and they're terminated `{ESC}\`, which is usually referred to as ST (String Terminator). That is unless you're xterm, and then you terminate OSC sequences with either ST or BELL (char 0x07). A lot of this makes more sense if you look at code rather than documentation. So I've made an effort to ensure my own terminal emulator's source code is as self-documenting as possible, eg[2] [1] https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_(Control_Sequence_Introducer)_sequences https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_(Control_... [2] https://github.com/lmorg/mxtty/blob/main/virtualterm/ansi_c1.go https://github.com/lmorg/mxtty/blob/main/virtualterm/ansi_c1...