unexpected behavior with commandline parameter for new profile #15979

Closed
opened 2026-01-31 04:53:54 +00:00 by claunia · 1 comment
Owner

Originally created by @awa5114 on GitHub (Nov 27, 2021).

Windows Terminal version

1.11.2921.0

Windows build number

10.0.19043.0

Other Software

No response

Steps to reproduce

  • Create new profile as follows:
          {
               "commandline": "powershell.exe -ExecutionPolicy ByPass -NoExit -Command '& echo hello'",
               "guid": "{75549856-2f4b-4e71-842a-48288c8f7250}",
               "hidden": false,
               "name": "Anaconda powershell prompt",
               "font": {
                 "size": 10
               }
           }
  • Open new tab with this profile

Expected Behavior

I was expecting for the string hello to appear before the prompt starts as specified in the commandline parameter

Actual Behavior

Instead, I get the string & echo hello

Originally created by @awa5114 on GitHub (Nov 27, 2021). ### Windows Terminal version 1.11.2921.0 ### Windows build number 10.0.19043.0 ### Other Software _No response_ ### Steps to reproduce - Create new profile as follows: ``` { "commandline": "powershell.exe -ExecutionPolicy ByPass -NoExit -Command '& echo hello'", "guid": "{75549856-2f4b-4e71-842a-48288c8f7250}", "hidden": false, "name": "Anaconda powershell prompt", "font": { "size": 10 } } ``` - Open new tab with this profile ### Expected Behavior I was expecting for the string `hello` to appear before the prompt starts as specified in the `commandline` parameter ### Actual Behavior Instead, I get the string `& echo hello`
claunia added the Issue-QuestionNeeds-TriageNeeds-Tag-FixResolution-Answered labels 2026-01-31 04:53:55 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Nov 29, 2021):

I think the ampersand is wrong - removing that, seems to work the way you'd expect.

Alternatively:

"powershell.exe -ExecutionPolicy ByPass -NoExit -Command &'Write-Output' 'hello'"

which will escape Write-Output as the command name, and hello as the arg(s)

@zadjii-msft commented on GitHub (Nov 29, 2021): I think the ampersand is wrong - removing that, seems to work the way you'd expect. Alternatively: ``` "powershell.exe -ExecutionPolicy ByPass -NoExit -Command &'Write-Output' 'hello'" ``` which will escape `Write-Output` as the command name, and `hello` as the arg(s)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#15979