Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

terminal.external.windowsExec not work as expected when path contains spaces #220129

Open
zhaojjiang opened this issue Jul 6, 2024 · 1 comment · May be fixed by #221258
Open

terminal.external.windowsExec not work as expected when path contains spaces #220129

zhaojjiang opened this issue Jul 6, 2024 · 1 comment · May be fixed by #221258
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug confirmation-pending help wanted Issues identified as good community contribution opportunities terminal-external

Comments

@zhaojjiang
Copy link

zhaojjiang commented Jul 6, 2024

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.91.0
  • OS Version: Windows_NT_x64 10.0.22631

Steps to Reproduce:

  1. install powershell 7.x
  2. set "terminal.external.windowsExec": "C:\\Program Files\\PowerShell\\7\\pwsh.exe"
  3. invoke external terminal by Ctrl+Shift+C
  4. the terminal title showing \\

Additional Info:

this happens not only with powershell 7.x, it may happen with all terminal which path contains space

I found relate code: externalTerminalService.ts#L40-L74, the code converted to node command is

# you can try this in node interactive shell, this will open a terminal with title \\
child_process.spawn('cmd.exe', ['/c', 'start', '/wait', '""', 'C:\\Program Files\\PowerShell\\7\\pwsh.exe'], {cwd: 'D:\\temp', detached: true})

the comment for externalTerminalService.ts#L57-L61 said "" used to solve something, but now it cause \\ showing,

if (exec.indexOf(' ') >= 0) {
    // The "" argument is the window title. Without this, exec doesn't work when the path
    // contains spaces
    cmdArgs.push('""');
}

but i tried node command above without '""' and works fine,
is this caused by system version or something else?

#  not ok
child_process.spawn('cmd.exe', ['/c', 'start', '/wait', '""', 'C:\\Program Files\\PowerShell\\7\\pwsh.exe'], {cwd: 'D:\\temp', detached: true})
# ok
child_process.spawn('cmd.exe', ['/c', 'start', '/wait', 'C:\\Program Files\\PowerShell\\7\\pwsh.exe'], {cwd: 'D:\\temp', detached: true})
@meganrogge meganrogge added bug Issue identified by VS Code Team member as probable bug help wanted Issues identified as good community contribution opportunities confirmation-pending terminal-external labels Jul 8, 2024
@tisilent
Copy link
Contributor

tisilent commented Jul 9, 2024

'""' => '\"\"'

@tisilent tisilent linked a pull request Jul 9, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug confirmation-pending help wanted Issues identified as good community contribution opportunities terminal-external
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants