Differences between Windows Terminal and the console host

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
atfon
Posts: 107
Joined: 06 Oct 2017 07:33

Differences between Windows Terminal and the console host

#1 Post by atfon » 15 Sep 2021 11:26

I've noticed some strange (to me) differences in behavior when running batch scripts or certain commands in the Windows Terminal versus in cmd.exe. For example, this command does nothing in the Windows Terminal application, but changes the console screen size in cmd.exe:

Code: Select all

mode con: cols=78 lines=27
I also noticed some strange artifacts on the screen when using the color command in Windows Terminal followed by dir and other commands:

Code: Select all

color 70
dir
Is there a list of these differences in behavior and others? My concern is that my batch scripts will not function the same with the Windows Terminal application. Thanks.
Last edited by atfon on 15 Sep 2021 12:46, edited 1 time in total.

aGerman
Expert
Posts: 4291
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Differences between Windows Terminal and cmd.exe

#2 Post by aGerman » 15 Sep 2021 11:53

First of all: Is your actual question about the difference between Windows Terminal and the console host?
I'm asking because the answer to the topic of your thread is that: https://github.com/microsoft/terminal/b ... s-terminal

Steffen

atfon
Posts: 107
Joined: 06 Oct 2017 07:33

Re: Differences between Windows Terminal and the console host

#3 Post by atfon » 15 Sep 2021 12:52

aGerman wrote:
15 Sep 2021 11:53
Is your actual question about the difference between Windows Terminal and the console host?
Steffen
My apologies. That's exactly right. I have updated the topic to reflect my inquiry. I had made a false assumption the the commands available to the console host from cmd.exe would be available when using the Command Prompt from within the Windows Terminal application. That's clearly not the case and it makes sense. It would be nice to know if there was a list of known commands which will not behave the same when using the Command Prompt from within the Windows Terminal application. I hope I have stated myself more clearly.

aGerman
Expert
Posts: 4291
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Differences between Windows Terminal and the console host

#4 Post by aGerman » 15 Sep 2021 13:56

I'm not aware of such a list.
It might be of interest for you to get a little background about where it's all coming from and to where they are going with the Windows Terminal There is a series of 5 chapters that Rich Turner wrote up, beginning with that one https://devblogs.microsoft.com/commandl ... kgrounder/

Basically both Windows Terminal and Conhost are Virtual Terminal Emulators.
In the beginning Microsoft still supported ANSI escape sequences. Later they only relied on the console API functions which made it rather impossible to update the formatting of text, to position the text cursor, to scroll the window, and stuff like that from within a script code. In parallel, 3rd party terminals and the terminals of other operating systems are based on rendering of VT sequences. So, you've been able to send those text streams to remote machines even between different OSs. Sending them to the old windows console, however, resulted in getting crap. The V2 console still supports the console API, but also quite some of the VT sequences. This goes hand in hand with the WSL because it uses the console by default and thus, it was necessary to render streams it receives from Linux shells. The Windows Terminal shares a lot of source code with Conhost. But the console API targets Conhost. Any functionality of the CMD (and other Windows console tools) that use the console API behind the scenes, may not work in Windows Terminal anymore. (MODE CON actually gives you a hint what it targets :wink:).
IMHO Microsoft is heading in the right direction with their Terminal. Having a common standard along with other VT emulators on other OSs, and publishing it as an open source project is something that I would never have expected 10 years ago. Something must have changed with Satya Nadella as CEO.

Steffen

atfon
Posts: 107
Joined: 06 Oct 2017 07:33

Re: Differences between Windows Terminal and the console host

#5 Post by atfon » 16 Sep 2021 06:21

aGerman wrote:
15 Sep 2021 13:56
Any functionality of the CMD (and other Windows console tools) that use the console API behind the scenes, may not work in Windows Terminal anymore. (MODE CON actually gives you a hint what it targets :wink:).
IMHO Microsoft is heading in the right direction with their Terminal. Having a common standard along with other VT emulators on other OSs, and publishing it as an open source project is something that I would never have expected 10 years ago. Something must have changed with Satya Nadella as CEO.

Steffen
Thanks, Steffen. That's an excellent overview article. Not to date myself, but I remember using those DEC VT100 terminals. :roll:

That makes sense that mode con might not work with the Windows Terminal application. I was just a bit surprised by the way the color command behaved. That might perhaps be a bug? I agree with you about Microsoft publishing as open source. I would not have expected that or to be able to use Ubuntu (WSL).

aGerman
Expert
Posts: 4291
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Differences between Windows Terminal and the console host

#6 Post by aGerman » 16 Sep 2021 09:54

I'm not sure if they implemented some workaround for the COLOR command. but it's quite likely. I recall that they updated the behavior of CLS which originally only cleared the viewport (the visible part of the terminal window) because this is what represents the screen on an old hardware-terminal and CLS is obviously for CLear Screen. However, too many people are used to clearing the entire buffer unsing CLS. And now the so-called history (old content which is scrolled out at the top of the viewport) is cleared, too. Maybe one day also MODE CON will work again. But until now resizing of the terminal is not supported at all, even though XTERM specified control sequences for this purpose.

Steffen

Post Reply