Skip to content

Unable to debug scripts in folder with ampersand in title #1400

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

Closed
DanrwAU opened this issue Jul 3, 2018 · 11 comments
Closed

Unable to debug scripts in folder with ampersand in title #1400

DanrwAU opened this issue Jul 3, 2018 · 11 comments
Assignees
Labels

Comments

@DanrwAU
Copy link

DanrwAU commented Jul 3, 2018

Issue Description

I am experiencing a problem with running debug on script residing in a folder path containing an ampersand.

When running these i get the following error:
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.

This works fine in ISE.

Unfortunately as this is a hardcoded onedrive path i can't easily modify this.

Attached Logs

Environment Information

Visual Studio Code

Name Version
Operating System Windows_NT x64 10.0.17134
VSCode 1.24.1
PowerShell Extension Version 1.7.0

PowerShell Information

Name Value
PSVersion 5.1.17134.112
PSEdition Desktop
PSCompatibleVersions 1.0 2.0 3.0 4.0 5.0 5.1.17134.112
BuildVersion 10.0.17134.112
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Visual Studio Code Extensions

Visual Studio Code Extensions(Click to Expand)
Extension Author Version
cisco jamiewoodio 1.0.1
Material-theme zhuangtongfa 2.15.0
one-monokai azemoh 0.3.4
PowerShell ms-vscode 1.7.0
slack-theme felipe-mendes 1.6.1
team ms-vsts 1.136.0
vscode-icons robertohuertasm 7.24.0
@Halkcyon
Copy link

Halkcyon commented Jul 6, 2018

It sounds like you're not quoting the path properly? That error is from powershell trying to parse an ampersand where it doesn't belong. Currently it's only supported in two locations: Redirection and as the call operator.

@rjmholt
Copy link
Contributor

rjmholt commented Jul 7, 2018

@Lowestkillcount Can you give an example of the path that isn't working? Also, have you tried this in PowerShell without VSCode? If it reproduces in PowerShell without VSCode, it would probably be a PowerShell issue (or could be by design).

@DanrwAU
Copy link
Author

DanrwAU commented Jul 7, 2018

Interestingly enough - i've just reopened the same file i was working on and this doesn't happen anymore.... however this is on a different PC so maybe something in the other environment..

The issue was when working on a file in path:
C:\Users\LKC\Onedrive - S&M Company Pty Ltd \Script.ps1

Using the Debug\Start Debugging option in the menu would result in the console throwing an error like below.

The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.

As when you do this the debugger runs the whole script path against the console like this
PowerShell Integrated Console

PS C:\Users\LKC\Onedrive - S&M Company Pty Ltd> c:\Users\LKC\Onedrive - S&M Company Pty Ltd \Script.ps1

I'll double check on my work laptop on Monday if it still occurs there, it may be some obscure setting in my profile causing issues.

@rjmholt rjmholt self-assigned this Aug 24, 2018
@rjmholt
Copy link
Contributor

rjmholt commented Aug 24, 2018

I'm having trouble reproducing this currently. @DanrwAU, are you still seeing this issue?

@rjmholt
Copy link
Contributor

rjmholt commented Oct 3, 2018

@DanrwAU are you still having this problem in 1.9.0? I fixed a URI issue that would explain this bug and curious to see if it persists.

@DanrwAU
Copy link
Author

DanrwAU commented Oct 3, 2018

Sorry missed the last update 😄

I haven't had it happen recently, i may have debugged a few times but generally i avoid using VSCode to debug as all my scripts live in a path with an ampersand.

I'll test it out and let you know

@rjmholt
Copy link
Contributor

rjmholt commented Oct 3, 2018

No worries — totally understand

@DanrwAU
Copy link
Author

DanrwAU commented Oct 4, 2018

PowerShell Integrated Console

. c:\Users\username\OneDrive` -` Company &Company` Corporation\Repositories\Office` 365\Migrate-Onedrive.ps1 -Verb RunAs

At line:1 char:42
+ . c:\Users\username\OneDrive` -` Company&Company` Corporation\Repositories ...
+                                          ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.

Still happening.

@rjmholt
Copy link
Contributor

rjmholt commented Oct 4, 2018

Bugger. I think we've just identified where the problem is at least, so a fix is within reach.

@rjmholt
Copy link
Contributor

rjmholt commented Oct 10, 2018

I have a fix for this in the PR shown above, so hopefully we can build a new extension pre-release artefact within the week for you to test @DanrwAU

@DanrwAU
Copy link
Author

DanrwAU commented Dec 17, 2018

Just confirming this seems to be fixed in the latest version of the Powershell extension great work👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants