DOSKEY aliases work unexpectedly #20700

Open
opened 2026-01-31 07:21:38 +00:00 by claunia · 10 comments
Owner

Originally created by @o-sdn-o on GitHub (Oct 20, 2023).

Windows Terminal version

current main

Windows build number

10.0.19045.3448

Other Software

No response

Steps to reproduce

According to https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/doskey

$T or $t Separates commands. Use either of these special characters to separate commands when you create macros or type commands on the doskey command line. These special characters are equivalent to using the ampersand (&) on a command line.

and https://ss64.com/nt/doskey.html

Advanced macro definitions:

$T If you put more than one command in a DOSKEY macro, use $T.
to separate them. Equivalent to & in a batch file.

the following commands

doskey test=echo 123 $t echo 456
test

and

echo 123 & echo 456

should give the same output.

Expected Behavior

C:\Users\sdn>doskey test=echo 123 $t echo 456

C:\Users\sdn>test
123
456

C:\Users\sdn>

Actual Behavior

C:\Users\sdn>doskey test=echo 123 $t echo 456

C:\Users\sdn>test
123

C:\Users\sdn>456

C:\Users\sdn>

Related to #14991

Originally created by @o-sdn-o on GitHub (Oct 20, 2023). ### Windows Terminal version current main ### Windows build number 10.0.19045.3448 ### Other Software _No response_ ### Steps to reproduce According to https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/doskey > $T or $t Separates commands. Use either of these special characters to separate commands when you create macros or type commands on the doskey command line. These special characters are equivalent to using the ampersand (&) on a command line. and https://ss64.com/nt/doskey.html > Advanced macro definitions: > > $T If you put more than one command in a DOSKEY macro, use $T. > to separate them. Equivalent to & in a batch file. the following commands ``` doskey test=echo 123 $t echo 456 test ``` and ``` echo 123 & echo 456 ``` should give the same output. ### Expected Behavior ``` C:\Users\sdn>doskey test=echo 123 $t echo 456 C:\Users\sdn>test 123 456 C:\Users\sdn> ``` ### Actual Behavior ``` C:\Users\sdn>doskey test=echo 123 $t echo 456 C:\Users\sdn>test 123 C:\Users\sdn>456 C:\Users\sdn> ``` Related to #14991
Author
Owner

@DHowett commented on GitHub (Oct 20, 2023):

Say, does this work properly for you on 1.18?

@DHowett commented on GitHub (Oct 20, 2023): Say, does this work properly for you on 1.18?
Author
Owner

@DHowett commented on GitHub (Oct 20, 2023):

From my own testing:

rs1

chop is incapable of loading conhostv2 from rs1. I can't test earlier than rs2.

rs2

image

broken

rs3

image

broken

rs5

image

broken

19h1

image

broken

@DHowett commented on GitHub (Oct 20, 2023): From my own testing: ### rs1 chop is incapable of loading `conhostv2` from rs1. I can't test earlier than rs2. ### rs2 <img width="432" alt="image" src="https://github.com/microsoft/terminal/assets/189190/44a006fc-6204-41d7-ab29-309bc32771c9"> broken ### rs3 <img width="567" alt="image" src="https://github.com/microsoft/terminal/assets/189190/53edcf5d-6084-4857-90d9-177592f983dc"> broken ### rs5 <img width="439" alt="image" src="https://github.com/microsoft/terminal/assets/189190/85a00b18-9d2f-410b-b648-ce0080aae511"> broken ### 19h1 <img width="431" alt="image" src="https://github.com/microsoft/terminal/assets/189190/e38e8299-61ed-4ebc-a5d3-21ca47ee9644"> broken
Author
Owner

@o-sdn-o commented on GitHub (Oct 21, 2023):

In release-1.18 branch the same result:

C:\Users\sdn>doskey test=echo 123 $t echo 456

C:\Users\sdn>test
123

C:\Users\sdn>456

C:\Users\sdn>
@o-sdn-o commented on GitHub (Oct 21, 2023): In `release-1.18` branch the same result: ``` C:\Users\sdn>doskey test=echo 123 $t echo 456 C:\Users\sdn>test 123 C:\Users\sdn>456 C:\Users\sdn> ```
Author
Owner

@o-sdn-o commented on GitHub (Oct 21, 2023):

In NT3.51/Win2K/WinXP/7/8.1 the same result as in Win10,

but in Windows 3.11 slightly different result:
image

Also, & does not work in Win311:
image

@o-sdn-o commented on GitHub (Oct 21, 2023): In NT3.51/Win2K/WinXP/7/8.1 the same result as in Win10, but in Windows 3.11 slightly different result: ![image](https://github.com/microsoft/terminal/assets/11535558/cb1512b9-011e-41ff-8f86-d265532667ef) Also, `&` does not work in Win311: ![image](https://github.com/microsoft/terminal/assets/11535558/2e84c0b8-7f38-42a6-ba3f-8d20ac5f3fd2)
Author
Owner

@o-sdn-o commented on GitHub (Oct 21, 2023):

It looks like the line command split (multicommand) first appeared in doskey and later in cmd.exe itself. And now if we suddenly decide to fix this behavior, we just need to replace $T with & during parsing the cooked read and send it to cmd.exe in one line without splitting into multiline.

@o-sdn-o commented on GitHub (Oct 21, 2023): It looks like the line command split (multicommand) first appeared in doskey and later in cmd.exe itself. And now if we suddenly decide to fix this behavior, we just need to replace `$T` with `&` during parsing the cooked read and send it to cmd.exe in one line without splitting into multiline.
Author
Owner

@237dmitry commented on GitHub (Oct 21, 2023):

doskey test=echo 123 ^& echo 345
@237dmitry commented on GitHub (Oct 21, 2023): ``` doskey test=echo 123 ^& echo 345 ```
Author
Owner

@o-sdn-o commented on GitHub (Oct 21, 2023):

In Win 3.11:
image

In WinNT 3.51
image

In Win2K:
image

In WinXP/7/8.1/10:
image

@o-sdn-o commented on GitHub (Oct 21, 2023): In Win 3.11: ![image](https://github.com/microsoft/terminal/assets/11535558/0191f2f0-9834-431d-8113-c43bfeb22c10) In WinNT 3.51 ![image](https://github.com/microsoft/terminal/assets/11535558/3e5c3eab-5173-48a3-8124-b0151b6a2f4d) In Win2K: ![image](https://github.com/microsoft/terminal/assets/11535558/79cd9b0a-2366-48b2-97d7-f5cc75234ba0) In WinXP/7/8.1/10: ![image](https://github.com/microsoft/terminal/assets/11535558/3652391d-1c78-48f3-9833-62960247dba2)
Author
Owner

@o-sdn-o commented on GitHub (Oct 21, 2023):

We can look at the use of $t and ^& tags in batch files by searching on github.

@o-sdn-o commented on GitHub (Oct 21, 2023): We can look at the use of [`$t`](https://github.com/search?q=doskey+%24t+%28path%3A*.cmd+OR+path%3A*.bat%29&type=Code&ref=advsearch&l=&l=) and [`^&`](https://github.com/search?q=doskey+%5E%26+%28path%3A*.cmd+OR+path%3A*.bat%29&type=Code&ref=advsearch&l=&l=) tags in batch files by searching on github.
Author
Owner

@o-sdn-o commented on GitHub (Oct 21, 2023):

So, it looks like this behavior has been going on since the beginning, when the TSR doskey was incorporated into the NT kernel.

@o-sdn-o commented on GitHub (Oct 21, 2023): So, it looks like this behavior has been going on since the beginning, when the TSR doskey was incorporated into the NT kernel.
Author
Owner

@DHowett commented on GitHub (Oct 23, 2023):

The issue is probably related to us printing the prompt again, not anything to do with us replacing $t with the right token. :)

@DHowett commented on GitHub (Oct 23, 2023): The issue is probably related to us printing the prompt again, not anything to do with us replacing `$t` with the right token. :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#20700