Disappering window after curl command #18531

Closed
opened 2026-01-31 06:16:55 +00:00 by claunia · 3 comments
Owner

Originally created by @lbaiao on GitHub (Sep 22, 2022).

Windows Terminal version

1.14.2282

Windows build number

10.0.22000.0

Other Software

PowerShell 7.2.6

Steps to reproduce

Run wt curl microsoft.com && ping microsoft.com -t in Windows Terminal in a PowerShell shell.

Expected Behavior

The Terminal should open a new Terminal window. Following, in the newly open window, it should run the curl command. After the curl command finishes, it should run the ping command, all in the same window.

Actual Behavior

The Terminal opens a new window and runs the curl command in this newly open window. After the curl command completion, it closes the new window and runs the ping command in the original window, where the whole command was input originally.

Originally created by @lbaiao on GitHub (Sep 22, 2022). ### Windows Terminal version 1.14.2282 ### Windows build number 10.0.22000.0 ### Other Software PowerShell 7.2.6 ### Steps to reproduce Run `wt curl microsoft.com && ping microsoft.com -t` in Windows Terminal in a PowerShell shell. ### Expected Behavior The Terminal should open a new Terminal window. Following, in the newly open window, it should run the `curl` command. After the `curl` command finishes, it should run the `ping` command, all in the same window. ### Actual Behavior The Terminal opens a new window and runs the `curl` command in this newly open window. After the `curl` command completion, it closes the new window and runs the `ping` command in the original window, where the whole command was input originally.
claunia added the Issue-QuestionNeeds-Tag-FixResolution-Answered labels 2026-01-31 06:16:55 +00:00
Author
Owner

@lhecker commented on GitHub (Sep 22, 2022):

&& has a special meaning to PowerShell and separates two commands. It's like writing ; in C-like languages. For instance try running this:

echo 1 && sleep 1 && echo 2

Furthermore, wt expects a command-line as the argument, which means that the first argument is interpreted as an executable name and all remaining arguments are passed to that executable. curl doesn't know what ping is. You have to launch a shell first, like pwsh, to make such concepts work.

So to make your command work try running this:

wt pwsh -c "curl microsoft.com && ping microsoft.com -t"

It instructs wt to spawn the executable named pwsh and passes it 2 parameters: -c which is short for -Command and the long string is the command argument. It tells pwsh to run the string as if it were a command.

@lhecker commented on GitHub (Sep 22, 2022): `&&` has a special meaning to PowerShell and separates two commands. It's like writing `;` in C-like languages. For instance try running this: ```pwsh echo 1 && sleep 1 && echo 2 ``` Furthermore, `wt` expects a command-line as the argument, which means that the first argument is interpreted as an executable name and all remaining arguments are passed to that executable. `curl` doesn't know what `ping` is. You have to launch a shell first, like `pwsh`, to make such concepts work. So to make your command work try running this: ```pwsh wt pwsh -c "curl microsoft.com && ping microsoft.com -t" ``` It instructs `wt` to spawn the executable named `pwsh` and passes it 2 parameters: `-c` which is short for `-Command` and the long string is the command argument. It tells `pwsh` to run the string as if it were a command.
Author
Owner

@lbaiao commented on GitHub (Sep 23, 2022):

Thanks a lot. Sorry for raising this issue, since it was not a bug after all. I read the documentation here, but I could not find this pwsh -c command in there. I thought it was a bit confusing. Maybe this documentation could be improved.

Also, thanks for the PowerShell explanation.

@lbaiao commented on GitHub (Sep 23, 2022): Thanks a lot. Sorry for raising this issue, since it was not a bug after all. I read the documentation [here](https://learn.microsoft.com/en-us/windows/terminal/command-line-arguments?tabs=powershell), but I could not find this `pwsh -c` command in there. I thought it was a bit confusing. Maybe this documentation could be improved. Also, thanks for the PowerShell explanation.
Author
Owner

@lhecker commented on GitHub (Sep 23, 2022):

That's not a problem. I'm glad I could help!

@lhecker commented on GitHub (Sep 23, 2022): That's not a problem. I'm glad I could help!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#18531