Parser removing all Quotationmarks before / when executing command in commandline field of any profile #20778

Closed
opened 2026-01-31 07:23:50 +00:00 by claunia · 12 comments
Owner

Originally created by @a-usr on GitHub (Nov 7, 2023).

Windows Terminal version

1.18.2822.0

Windows build number

10.0.19045.0

Other Software

No response

Steps to reproduce

Create a profile that contains quotation marks in the commandline field (from within windows terminal)

Expected Behavior

Quotation marks stay where they are

Actual Behavior

command in commandline field is being executed without any quotationmarks, even though they very much exist both in json (escaped) and in the windows terminal editor

Originally created by @a-usr on GitHub (Nov 7, 2023). ### Windows Terminal version 1.18.2822.0 ### Windows build number 10.0.19045.0 ### Other Software _No response_ ### Steps to reproduce Create a profile that contains quotation marks in the commandline field (from within windows terminal) ### Expected Behavior Quotation marks stay where they are ### Actual Behavior command in commandline field is being executed without any quotationmarks, even though they very much exist both in json (escaped) and in the windows terminal editor
claunia added the Needs-TriageIssue-BugResolution-ExternalNeeds-Attention labels 2026-01-31 07:23:50 +00:00
Author
Owner

@DHowett commented on GitHub (Nov 7, 2023):

Can you share your settings.json as well as the issue you're seeing when you launch that profile?

@DHowett commented on GitHub (Nov 7, 2023): Can you share your `settings.json` as well as the issue you're seeing when you _launch_ that profile?
Author
Owner

@a-usr commented on GitHub (Nov 8, 2023):

settings.json with all other unnecessary profiles removed:

    "$help": "https://aka.ms/terminal-documentation",
    "$schema": "https://aka.ms/terminal-profiles-schema",
    "actions": 
    [
        {
            "command": 
            {
                "action": "copy",
                "singleLine": false
            },
            "keys": "ctrl+c"
        },
        {
            "command": "paste",
            "keys": "ctrl+v"
        },
        {
            "command": 
            {
                "action": "splitPane",
                "split": "right",
                "splitMode": "duplicate"
            },
            "keys": "alt+shift+plus"
        },
        {
            "command": 
            {
                "action": "splitPane",
                "split": "down",
                "splitMode": "duplicate"
            },
            "keys": "alt+shift+minus"
        },
        {
            "command": 
            {
                "action": "splitPane",
                "split": "auto",
                "splitMode": "duplicate"
            },
            "keys": "alt+shift+d"
        },
        {
            "command": "find",
            "keys": "ctrl+shift+f"
        }
    ],
    "alwaysShowNotificationIcon": true,
    "copyFormatting": "none",
    "copyOnSelect": false,
    "defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
    "disableAnimations": false,
    "experimental.rendering.forceFullRepaint": false,
    "newTabMenu": 
    [
        {
            "type": "remainingProfiles"
        }
    ],
    "profiles": 
    {
        "defaults": 
        {
            "altGrAliasing": true,
            "experimental.retroTerminalEffect": false,
            "font": 
            {
                "face": "Cascadia Code"
            },
            "useAtlasEngine": true
        },
        "list": 
        [
            {
                "antialiasingMode": "grayscale",
                "closeOnExit": "automatic",
                "colorScheme": "One Half Dark",
                "commandline": "C:\\Users\\MYUSERNAME\\.dotnet\\tools\\pwsh.exe -NoExit -Command \"& ([ScriptBlock]::Create((oh-my-posh init pwsh --config \"$env:POSH_THEMES_PATH\\jandedobbeleer.omp.json\" --print) -join \"`n\"))\"",
                "cursorShape": "underscore",
                "experimental.retroTerminalEffect": false,
                "font": 
                {
                    "face": "Hurmit Nerd Font Mono",
                    "size": 12.0
                },
                "guid": "{05a17ce8-dc9a-460c-a7ab-eaa94feb108c}",
                "hidden": false,
                "historySize": 9001,
                "icon": "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png",
                "name": "ERROR APPEARS HERE",
                "padding": "8, 8, 8, 8",
                "snapOnInput": true,
                "startingDirectory": "%USERPROFILE%",
                "suppressApplicationTitle": false,
                "useAcrylic": true
            }
        ]
    },
    "schemes": 
    [
        {
            "background": "#0C0C0C",
            "black": "#0C0C0C",
            "blue": "#0037DA",
            "brightBlack": "#767676",
            "brightBlue": "#3B78FF",
            "brightCyan": "#61D6D6",
            "brightGreen": "#16C60C",
            "brightPurple": "#B4009E",
            "brightRed": "#E74856",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#F9F1A5",
            "cursorColor": "#FFFFFF",
            "cyan": "#3A96DD",
            "foreground": "#CCCCCC",
            "green": "#13A10E",
            "name": "Campbell",
            "purple": "#881798",
            "red": "#C50F1F",
            "selectionBackground": "#FFFFFF",
            "white": "#CCCCCC",
            "yellow": "#C19C00"
        },
        {
            "background": "#012456",
            "black": "#0C0C0C",
            "blue": "#0037DA",
            "brightBlack": "#767676",
            "brightBlue": "#3B78FF",
            "brightCyan": "#61D6D6",
            "brightGreen": "#16C60C",
            "brightPurple": "#B4009E",
            "brightRed": "#E74856",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#F9F1A5",
            "cursorColor": "#FFFFFF",
            "cyan": "#3A96DD",
            "foreground": "#CCCCCC",
            "green": "#13A10E",
            "name": "Campbell Powershell",
            "purple": "#881798",
            "red": "#C50F1F",
            "selectionBackground": "#FFFFFF",
            "white": "#CCCCCC",
            "yellow": "#C19C00"
        },
        {
            "background": "#000000",
            "black": "#0C0C0C",
            "blue": "#000000",
            "brightBlack": "#767676",
            "brightBlue": "#3B78FF",
            "brightCyan": "#61D6D6",
            "brightGreen": "#16C60C",
            "brightPurple": "#B4009E",
            "brightRed": "#000000",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#F9F1A5",
            "cursorColor": "#FFFFFF",
            "cyan": "#000000",
            "foreground": "#FFFFFF",
            "green": "#000000",
            "name": "Color Scheme 10",
            "purple": "#000000",
            "red": "#000000",
            "selectionBackground": "#FFFFFF",
            "white": "#000000",
            "yellow": "#000000"
        },
        {
            "background": "#282C34",
            "black": "#282C34",
            "blue": "#4E8CBF",
            "brightBlack": "#5A6374",
            "brightBlue": "#61AFEF",
            "brightCyan": "#56B6C2",
            "brightGreen": "#98C379",
            "brightPurple": "#C678DD",
            "brightRed": "#E06C75",
            "brightWhite": "#DCDFE4",
            "brightYellow": "#E5C07B",
            "cursorColor": "#FFFFFF",
            "cyan": "#4FA7B3",
            "foreground": "#DCDFE4",
            "green": "#8BB36F",
            "name": "One Half Dark",
            "purple": "#AB68BF",
            "red": "#BF5C64",
            "selectionBackground": "#FFFFFF",
            "white": "#D1D4D9",
            "yellow": "#BFA067"
        },
        {
            "background": "#FAFAFA",
            "black": "#383A42",
            "blue": "#0184BC",
            "brightBlack": "#4F525D",
            "brightBlue": "#61AFEF",
            "brightCyan": "#56B5C1",
            "brightGreen": "#98C379",
            "brightPurple": "#C577DD",
            "brightRed": "#DF6C75",
            "brightWhite": "#FFFFFF",
            "brightYellow": "#E4C07A",
            "cursorColor": "#4F525D",
            "cyan": "#0997B3",
            "foreground": "#383A42",
            "green": "#50A14F",
            "name": "One Half Light",
            "purple": "#A626A4",
            "red": "#E45649",
            "selectionBackground": "#FFFFFF",
            "white": "#FAFAFA",
            "yellow": "#C18301"
        },
        {
            "background": "#002B36",
            "black": "#002B36",
            "blue": "#268BD2",
            "brightBlack": "#073642",
            "brightBlue": "#839496",
            "brightCyan": "#93A1A1",
            "brightGreen": "#586E75",
            "brightPurple": "#6C71C4",
            "brightRed": "#CB4B16",
            "brightWhite": "#FDF6E3",
            "brightYellow": "#657B83",
            "cursorColor": "#FFFFFF",
            "cyan": "#2AA198",
            "foreground": "#839496",
            "green": "#859900",
            "name": "Solarized Dark",
            "purple": "#D33682",
            "red": "#DC322F",
            "selectionBackground": "#FFFFFF",
            "white": "#EEE8D5",
            "yellow": "#B58900"
        },
        {
            "background": "#FDF6E3",
            "black": "#002B36",
            "blue": "#268BD2",
            "brightBlack": "#073642",
            "brightBlue": "#839496",
            "brightCyan": "#93A1A1",
            "brightGreen": "#586E75",
            "brightPurple": "#6C71C4",
            "brightRed": "#CB4B16",
            "brightWhite": "#FDF6E3",
            "brightYellow": "#657B83",
            "cursorColor": "#002B36",
            "cyan": "#2AA198",
            "foreground": "#657B83",
            "green": "#859900",
            "name": "Solarized Light",
            "purple": "#D33682",
            "red": "#DC322F",
            "selectionBackground": "#FFFFFF",
            "white": "#EEE8D5",
            "yellow": "#B58900"
        },
        {
            "background": "#000000",
            "black": "#000000",
            "blue": "#3465A4",
            "brightBlack": "#555753",
            "brightBlue": "#729FCF",
            "brightCyan": "#34E2E2",
            "brightGreen": "#8AE234",
            "brightPurple": "#AD7FA8",
            "brightRed": "#EF2929",
            "brightWhite": "#EEEEEC",
            "brightYellow": "#FCE94F",
            "cursorColor": "#FFFFFF",
            "cyan": "#06989A",
            "foreground": "#D3D7CF",
            "green": "#4E9A06",
            "name": "Tango Dark",
            "purple": "#75507B",
            "red": "#CC0000",
            "selectionBackground": "#FFFFFF",
            "white": "#D3D7CF",
            "yellow": "#C4A000"
        },
        {
            "background": "#FFFFFF",
            "black": "#000000",
            "blue": "#3465A4",
            "brightBlack": "#555753",
            "brightBlue": "#729FCF",
            "brightCyan": "#34E2E2",
            "brightGreen": "#8AE234",
            "brightPurple": "#AD7FA8",
            "brightRed": "#EF2929",
            "brightWhite": "#EEEEEC",
            "brightYellow": "#FCE94F",
            "cursorColor": "#000000",
            "cyan": "#06989A",
            "foreground": "#555753",
            "green": "#4E9A06",
            "name": "Tango Light",
            "purple": "#75507B",
            "red": "#CC0000",
            "selectionBackground": "#FFFFFF",
            "white": "#D3D7CF",
            "yellow": "#C4A000"
        },
        {
            "background": "#000000",
            "black": "#000000",
            "blue": "#000080",
            "brightBlack": "#808080",
            "brightBlue": "#0000FF",
            "brightCyan": "#00FFFF",
            "brightGreen": "#00FF00",
            "brightPurple": "#FF00FF",
            "brightRed": "#FF0000",
            "brightWhite": "#FFFFFF",
            "brightYellow": "#FFFF00",
            "cursorColor": "#FFFFFF",
            "cyan": "#008080",
            "foreground": "#C0C0C0",
            "green": "#008000",
            "name": "Vintage",
            "purple": "#800080",
            "red": "#800000",
            "selectionBackground": "#FFFFFF",
            "white": "#C0C0C0",
            "yellow": "#808000"
        }
    ],
    "showTabsInTitlebar": true,
    "theme": "dark",
    "themes": [],
    "useAcrylicInTabRow": true
}

The line in Question (From Settings.json):

"commandline": "C:\\Users\\MYUSERNAME\\.dotnet\\tools\\pwsh.exe -NoExit -Command \"& ([ScriptBlock]::Create((oh-my-posh init pwsh --config \"$env:POSH_THEMES_PATH\\jandedobbeleer.omp.json\" --print) -join \"`n\"))\"",

Un-Escaped Form (how I entered it in Windows Terminal and how it's displayed):

C:\Users\jz38763\.dotnet\tools\pwsh.exe -NoExit -Command "& ([ScriptBlock]::Create((oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\jandedobbeleer.omp.json" --print) -join "`n"))"

And the output:

Line |
   1 |  … fig $env:POSH_THEMES_PATH\jandedobbeleer.omp.json --print) -join `n))
     |                                                                    ~
     | You must provide a value expression following the '-join' operator.

Output is generated by the pwsh executable.

@a-usr commented on GitHub (Nov 8, 2023): settings.json with all other unnecessary profiles removed: ```{ "$help": "https://aka.ms/terminal-documentation", "$schema": "https://aka.ms/terminal-profiles-schema", "actions": [ { "command": { "action": "copy", "singleLine": false }, "keys": "ctrl+c" }, { "command": "paste", "keys": "ctrl+v" }, { "command": { "action": "splitPane", "split": "right", "splitMode": "duplicate" }, "keys": "alt+shift+plus" }, { "command": { "action": "splitPane", "split": "down", "splitMode": "duplicate" }, "keys": "alt+shift+minus" }, { "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" }, { "command": "find", "keys": "ctrl+shift+f" } ], "alwaysShowNotificationIcon": true, "copyFormatting": "none", "copyOnSelect": false, "defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", "disableAnimations": false, "experimental.rendering.forceFullRepaint": false, "newTabMenu": [ { "type": "remainingProfiles" } ], "profiles": { "defaults": { "altGrAliasing": true, "experimental.retroTerminalEffect": false, "font": { "face": "Cascadia Code" }, "useAtlasEngine": true }, "list": [ { "antialiasingMode": "grayscale", "closeOnExit": "automatic", "colorScheme": "One Half Dark", "commandline": "C:\\Users\\MYUSERNAME\\.dotnet\\tools\\pwsh.exe -NoExit -Command \"& ([ScriptBlock]::Create((oh-my-posh init pwsh --config \"$env:POSH_THEMES_PATH\\jandedobbeleer.omp.json\" --print) -join \"`n\"))\"", "cursorShape": "underscore", "experimental.retroTerminalEffect": false, "font": { "face": "Hurmit Nerd Font Mono", "size": 12.0 }, "guid": "{05a17ce8-dc9a-460c-a7ab-eaa94feb108c}", "hidden": false, "historySize": 9001, "icon": "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png", "name": "ERROR APPEARS HERE", "padding": "8, 8, 8, 8", "snapOnInput": true, "startingDirectory": "%USERPROFILE%", "suppressApplicationTitle": false, "useAcrylic": true } ] }, "schemes": [ { "background": "#0C0C0C", "black": "#0C0C0C", "blue": "#0037DA", "brightBlack": "#767676", "brightBlue": "#3B78FF", "brightCyan": "#61D6D6", "brightGreen": "#16C60C", "brightPurple": "#B4009E", "brightRed": "#E74856", "brightWhite": "#F2F2F2", "brightYellow": "#F9F1A5", "cursorColor": "#FFFFFF", "cyan": "#3A96DD", "foreground": "#CCCCCC", "green": "#13A10E", "name": "Campbell", "purple": "#881798", "red": "#C50F1F", "selectionBackground": "#FFFFFF", "white": "#CCCCCC", "yellow": "#C19C00" }, { "background": "#012456", "black": "#0C0C0C", "blue": "#0037DA", "brightBlack": "#767676", "brightBlue": "#3B78FF", "brightCyan": "#61D6D6", "brightGreen": "#16C60C", "brightPurple": "#B4009E", "brightRed": "#E74856", "brightWhite": "#F2F2F2", "brightYellow": "#F9F1A5", "cursorColor": "#FFFFFF", "cyan": "#3A96DD", "foreground": "#CCCCCC", "green": "#13A10E", "name": "Campbell Powershell", "purple": "#881798", "red": "#C50F1F", "selectionBackground": "#FFFFFF", "white": "#CCCCCC", "yellow": "#C19C00" }, { "background": "#000000", "black": "#0C0C0C", "blue": "#000000", "brightBlack": "#767676", "brightBlue": "#3B78FF", "brightCyan": "#61D6D6", "brightGreen": "#16C60C", "brightPurple": "#B4009E", "brightRed": "#000000", "brightWhite": "#F2F2F2", "brightYellow": "#F9F1A5", "cursorColor": "#FFFFFF", "cyan": "#000000", "foreground": "#FFFFFF", "green": "#000000", "name": "Color Scheme 10", "purple": "#000000", "red": "#000000", "selectionBackground": "#FFFFFF", "white": "#000000", "yellow": "#000000" }, { "background": "#282C34", "black": "#282C34", "blue": "#4E8CBF", "brightBlack": "#5A6374", "brightBlue": "#61AFEF", "brightCyan": "#56B6C2", "brightGreen": "#98C379", "brightPurple": "#C678DD", "brightRed": "#E06C75", "brightWhite": "#DCDFE4", "brightYellow": "#E5C07B", "cursorColor": "#FFFFFF", "cyan": "#4FA7B3", "foreground": "#DCDFE4", "green": "#8BB36F", "name": "One Half Dark", "purple": "#AB68BF", "red": "#BF5C64", "selectionBackground": "#FFFFFF", "white": "#D1D4D9", "yellow": "#BFA067" }, { "background": "#FAFAFA", "black": "#383A42", "blue": "#0184BC", "brightBlack": "#4F525D", "brightBlue": "#61AFEF", "brightCyan": "#56B5C1", "brightGreen": "#98C379", "brightPurple": "#C577DD", "brightRed": "#DF6C75", "brightWhite": "#FFFFFF", "brightYellow": "#E4C07A", "cursorColor": "#4F525D", "cyan": "#0997B3", "foreground": "#383A42", "green": "#50A14F", "name": "One Half Light", "purple": "#A626A4", "red": "#E45649", "selectionBackground": "#FFFFFF", "white": "#FAFAFA", "yellow": "#C18301" }, { "background": "#002B36", "black": "#002B36", "blue": "#268BD2", "brightBlack": "#073642", "brightBlue": "#839496", "brightCyan": "#93A1A1", "brightGreen": "#586E75", "brightPurple": "#6C71C4", "brightRed": "#CB4B16", "brightWhite": "#FDF6E3", "brightYellow": "#657B83", "cursorColor": "#FFFFFF", "cyan": "#2AA198", "foreground": "#839496", "green": "#859900", "name": "Solarized Dark", "purple": "#D33682", "red": "#DC322F", "selectionBackground": "#FFFFFF", "white": "#EEE8D5", "yellow": "#B58900" }, { "background": "#FDF6E3", "black": "#002B36", "blue": "#268BD2", "brightBlack": "#073642", "brightBlue": "#839496", "brightCyan": "#93A1A1", "brightGreen": "#586E75", "brightPurple": "#6C71C4", "brightRed": "#CB4B16", "brightWhite": "#FDF6E3", "brightYellow": "#657B83", "cursorColor": "#002B36", "cyan": "#2AA198", "foreground": "#657B83", "green": "#859900", "name": "Solarized Light", "purple": "#D33682", "red": "#DC322F", "selectionBackground": "#FFFFFF", "white": "#EEE8D5", "yellow": "#B58900" }, { "background": "#000000", "black": "#000000", "blue": "#3465A4", "brightBlack": "#555753", "brightBlue": "#729FCF", "brightCyan": "#34E2E2", "brightGreen": "#8AE234", "brightPurple": "#AD7FA8", "brightRed": "#EF2929", "brightWhite": "#EEEEEC", "brightYellow": "#FCE94F", "cursorColor": "#FFFFFF", "cyan": "#06989A", "foreground": "#D3D7CF", "green": "#4E9A06", "name": "Tango Dark", "purple": "#75507B", "red": "#CC0000", "selectionBackground": "#FFFFFF", "white": "#D3D7CF", "yellow": "#C4A000" }, { "background": "#FFFFFF", "black": "#000000", "blue": "#3465A4", "brightBlack": "#555753", "brightBlue": "#729FCF", "brightCyan": "#34E2E2", "brightGreen": "#8AE234", "brightPurple": "#AD7FA8", "brightRed": "#EF2929", "brightWhite": "#EEEEEC", "brightYellow": "#FCE94F", "cursorColor": "#000000", "cyan": "#06989A", "foreground": "#555753", "green": "#4E9A06", "name": "Tango Light", "purple": "#75507B", "red": "#CC0000", "selectionBackground": "#FFFFFF", "white": "#D3D7CF", "yellow": "#C4A000" }, { "background": "#000000", "black": "#000000", "blue": "#000080", "brightBlack": "#808080", "brightBlue": "#0000FF", "brightCyan": "#00FFFF", "brightGreen": "#00FF00", "brightPurple": "#FF00FF", "brightRed": "#FF0000", "brightWhite": "#FFFFFF", "brightYellow": "#FFFF00", "cursorColor": "#FFFFFF", "cyan": "#008080", "foreground": "#C0C0C0", "green": "#008000", "name": "Vintage", "purple": "#800080", "red": "#800000", "selectionBackground": "#FFFFFF", "white": "#C0C0C0", "yellow": "#808000" } ], "showTabsInTitlebar": true, "theme": "dark", "themes": [], "useAcrylicInTabRow": true } ``` The line in Question (From Settings.json): ``` "commandline": "C:\\Users\\MYUSERNAME\\.dotnet\\tools\\pwsh.exe -NoExit -Command \"& ([ScriptBlock]::Create((oh-my-posh init pwsh --config \"$env:POSH_THEMES_PATH\\jandedobbeleer.omp.json\" --print) -join \"`n\"))\"", ``` Un-Escaped Form (how I entered it in Windows Terminal and how it's displayed): ``` C:\Users\jz38763\.dotnet\tools\pwsh.exe -NoExit -Command "& ([ScriptBlock]::Create((oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\jandedobbeleer.omp.json" --print) -join "`n"))" ``` And the output: ```ParserError: Line | 1 | … fig $env:POSH_THEMES_PATH\jandedobbeleer.omp.json --print) -join `n)) | ~ | You must provide a value expression following the '-join' operator. ``` Output is generated by the pwsh executable.
Author
Owner

@lhecker commented on GitHub (Nov 8, 2023):

When you write something like "foo "bar" baz" then pwsh (and pretty much all other terminal applications) will treat this as

  • "foo "
  • bar
  • " baz"
    because you didn't escape the quotes inside the quotes. You can do that by using \", but as you noticed you need to escape quotes and backslashes in JSON as well, so this turns into \\\".
    Alternatively you can use single quotes ' inside a double quoted "..." argument, but only if the inner string doesn't contain $variables. That is because powershell treats '...' strings as literal strings, even if the '...' quotes are the outermost quotes. As an example, press Win+R and run this:
pwsh.exe -NoExit -Command '"foo bar".Length'

this will print out the literal string

"foo bar".Length

whereas if you run

pwsh.exe -NoExit -Command "'foo bar'.Length"

it'll print 7, because that's the length of the string 'foo bar' and the outermost quotes are double quotes, meaning they aren't treated as a literal string.

In any case you need to do:

"commandline": "C:\\Users\\jz38763\\.dotnet\\tools\\pwsh.exe -NoExit -Command \"& ([ScriptBlock]::Create((oh-my-posh init pwsh --config \\\"$env:POSH_THEMES_PATH\\jandedobbeleer.omp.json\\\" --print) -join \\\"`n\\\"))\"",
@lhecker commented on GitHub (Nov 8, 2023): When you write something like `"foo "bar" baz"` then pwsh (and pretty much all other terminal applications) will treat this as * `"foo "` * `bar` * `" baz"` because you didn't escape the quotes inside the quotes. You can do that by using `\"`, but as you noticed you need to escape quotes and backslashes in JSON as well, so this turns into `\\\"`. Alternatively you can use single quotes `'` inside a double quoted `"..."` argument, but only if the inner string doesn't contain `$variables`. That is because powershell treats `'...'` strings as literal strings, even if the `'...'` quotes are the outermost quotes. As an example, press Win+R and run this: ``` pwsh.exe -NoExit -Command '"foo bar".Length' ``` this will print out the literal string > "foo bar".Length whereas if you run ``` pwsh.exe -NoExit -Command "'foo bar'.Length" ``` it'll print `7`, because that's the length of the string `'foo bar'` and the outermost quotes are double quotes, meaning they aren't treated as a literal string. In any case you need to do: ```json "commandline": "C:\\Users\\jz38763\\.dotnet\\tools\\pwsh.exe -NoExit -Command \"& ([ScriptBlock]::Create((oh-my-posh init pwsh --config \\\"$env:POSH_THEMES_PATH\\jandedobbeleer.omp.json\\\" --print) -join \\\"`n\\\"))\"", ```
Author
Owner

@a-usr commented on GitHub (Nov 8, 2023):

This didn't change anything. I still get the same error as before.

Edit: Assuming Windows Terminal calls cmd.exe to execute the "commandline" field, it might actually be cmd.exe's fault. When doing "C:\Users\MYUSERNAME.dotnet\tools\pwsh.exe -NoExit -Command "& ([ScriptBlock]::Create((oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\jandedobbeleer.omp.json" --print) -join "`n"))" from cmd, I get the error I already showed:

ParserError:
Line |
   1 |  … fig $env:POSH_THEMES_PATH\jandedobbeleer.omp.json --print) -join `n))
     |                                                                    ~
     | You must provide a value expression following the '-join' operator.

In Powershell (pwsh) however I get the following:

ParserError:
Line |
   1 |  … cal\Programs\oh-my-posh\themes\jandedobbeleer.omp.json --print) -join
     |                                                                         ~
     | You must provide a value expression following the '-join' operator.

On a side Note: Powershell escapes double-qotes with \` instead of just \
Thus, in powershell, this
C:\Users\MYUSERNAME\.dotnet\tools\pwsh.exe -NoExit -Command "& ([ScriptBlock]::Create((oh-my-posh init pwsh --config \`"$env:POSH_THEMES_PATH\jandedobbeleer.omp.json\`" --print) -join \`"`n`\`")
would work.
In cmd however, I get this Error:

ParserError:
Line |
   1 |  … env:POSH_THEMES_PATH\jandedobbeleer.omp.json\` --print) -join \``n`\` …
     |                                                                 ~
     | You must provide a value expression following the '-join' operator.

The same error presents itself when i aditionally escape the doublequotes cmd-style:
C:\Users\MYUSERNAME\.dotnet\tools\pwsh.exe -NoExit -Command "& ([ScriptBlock]::Create((oh-my-posh init pwsh --config \`\"$env:POSH_THEMES_PATH\jandedobbeleer.omp.json\`\" --print) -join \`\"`n`\`\"))"
This further prooves that infact cmd is removing the double quotes.

@a-usr commented on GitHub (Nov 8, 2023): This didn't change anything. I still get the same error as before. Edit: Assuming Windows Terminal calls cmd.exe to execute the "commandline" field, it might actually be cmd.exe's fault. When doing "C:\Users\MYUSERNAME\.dotnet\tools\pwsh.exe -NoExit -Command "& ([ScriptBlock]::Create((oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\jandedobbeleer.omp.json" --print) -join "`n"))" from cmd, I get the error I already showed: ``` ParserError: Line | 1 | … fig $env:POSH_THEMES_PATH\jandedobbeleer.omp.json --print) -join `n)) | ~ | You must provide a value expression following the '-join' operator. ``` In Powershell (pwsh) however I get the following: ``` ParserError: Line | 1 | … cal\Programs\oh-my-posh\themes\jandedobbeleer.omp.json --print) -join | ~ | You must provide a value expression following the '-join' operator. ``` On a side Note: Powershell escapes double-qotes with ``` \` ``` instead of just ` \ ` Thus, in powershell, this ``` C:\Users\MYUSERNAME\.dotnet\tools\pwsh.exe -NoExit -Command "& ([ScriptBlock]::Create((oh-my-posh init pwsh --config \`"$env:POSH_THEMES_PATH\jandedobbeleer.omp.json\`" --print) -join \`"`n`\`") ``` would work. In cmd however, I get this Error: ``` ParserError: Line | 1 | … env:POSH_THEMES_PATH\jandedobbeleer.omp.json\` --print) -join \``n`\` … | ~ | You must provide a value expression following the '-join' operator. ``` The same error presents itself when i aditionally escape the doublequotes cmd-style: ``` C:\Users\MYUSERNAME\.dotnet\tools\pwsh.exe -NoExit -Command "& ([ScriptBlock]::Create((oh-my-posh init pwsh --config \`\"$env:POSH_THEMES_PATH\jandedobbeleer.omp.json\`\" --print) -join \`\"`n`\`\"))" ``` This further prooves that infact cmd is removing the double quotes.
Author
Owner

@lhecker commented on GitHub (Nov 8, 2023):

We pass the command line directly to CreateProcess. My suggestion above works for me:
image

I'll reopen it and maybe someone else has an idea why we see a different behavior.

@lhecker commented on GitHub (Nov 8, 2023): We pass the command line directly to `CreateProcess`. My suggestion above works for me: ![image](https://github.com/microsoft/terminal/assets/2256941/14e6c464-dc1c-4e9d-b342-dc53db4bb2d3) I'll reopen it and maybe someone else has an idea why we see a different behavior.
Author
Owner

@a-usr commented on GitHub (Nov 8, 2023):

Does windows by any chance enforce a default command prompt application? Also worth noting is that i am currently on a Windows 10 machine, while you appear to be on Windows 11.

@a-usr commented on GitHub (Nov 8, 2023): Does windows by any chance enforce a default command prompt application? Also worth noting is that i am currently on a Windows 10 machine, while you appear to be on Windows 11.
Author
Owner

@lhecker commented on GitHub (Nov 8, 2023):

Does windows by any chance enforce a default command prompt application?

You mean one that would influence how parameters given to CreateProcess are escaped? Then no. The command line given to CreateProcess is given 1:1 to the created process which can parse it however it likes to. Which is why...

Also worth noting is that i am currently on a Windows 10 machine, while you appear to be on Windows 11.

...I think that if anything, the most likely cause of this difference is us using different PowerShell versions. I'm on v7.3 - try it out if you're on an older version! https://github.com/PowerShell/PowerShell/issues/1995 made significant changes to their command line parsing and only got merged into v7.3 after all.

@lhecker commented on GitHub (Nov 8, 2023): > Does windows by any chance enforce a default command prompt application? You mean one that would influence how parameters given to `CreateProcess` are escaped? Then no. The command line given to `CreateProcess` is given 1:1 to the created process which can parse it however it likes to. Which is why... > Also worth noting is that i am currently on a Windows 10 machine, while you appear to be on Windows 11. ...I think that if anything, the most likely cause of this difference is us using different PowerShell versions. I'm on v7.3 - try it out if you're on an older version! https://github.com/PowerShell/PowerShell/issues/1995 made significant changes to their command line parsing and only got merged into v7.3 after all.
Author
Owner

@a-usr commented on GitHub (Nov 8, 2023):

I am currently using v7.3.9. Also, as you might have guessed, I installed Powershell using dotnet tool (the reason for that being that i am on a machine that i dont have administrative permissions for)

@a-usr commented on GitHub (Nov 8, 2023): I am currently using v7.3.9. Also, as you might have guessed, I installed Powershell using dotnet tool (the reason for that being that i am on a machine that i dont have administrative permissions for)
Author
Owner

@237dmitry commented on GitHub (Nov 8, 2023):

Isn't it easier to configure pwsh $Profile?

@237dmitry commented on GitHub (Nov 8, 2023): Isn't it easier to configure pwsh `$Profile`?
Author
Owner

@DHowett commented on GitHub (Nov 8, 2023):

Whoa! I just connected the dots.

The version of PowerShell that runs as a dotnet global tool has an extra wrapper .exe file, which calls the actual powershell exe later.

That is the difference between your environment @lhecker and @a-usr's environment!

This would not be the first time there was a bug in the PowerShell dotnet global tool wrapper. The ideal place to report bugs like this is on the PowerShell repository!

@DHowett commented on GitHub (Nov 8, 2023): _Whoa!_ I just connected the dots. The version of PowerShell that runs as a dotnet global tool has an extra wrapper `.exe` file, which calls the actual powershell exe later. That is the difference between your environment @lhecker and @a-usr's environment! This would not be the first time there was a bug in the PowerShell dotnet global tool wrapper. The ideal place to report bugs like this is on [the PowerShell repository](https://github.com/powershell/powershell)!
Author
Owner

@DHowett commented on GitHub (Nov 8, 2023):

Looking a bit deeper, it looks like this (currently open) issue: https://github.com/PowerShell/PowerShell/issues/11747

@DHowett commented on GitHub (Nov 8, 2023): Looking a bit deeper, it looks like this (currently open) issue: https://github.com/PowerShell/PowerShell/issues/11747
Author
Owner

@a-usr commented on GitHub (Nov 8, 2023):

Isn't it easier to configure pwsh $Profile?

yes, but only if you have admin access to change the execution policy or know how to sign the $Profile properly (the ms tutorial for that doesn't exactly work)

@a-usr commented on GitHub (Nov 8, 2023): > Isn't it easier to configure pwsh `$Profile`? yes, but only if you have admin access to change the execution policy or know how to sign the $Profile properly (the ms tutorial for that doesn't exactly work)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#20778