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

Breakpoints not honored in file name with square brackets in name #123

Closed
rkeithhill opened this issue Feb 2, 2016 · 5 comments
Closed
Assignees
Labels
Issue-Bug A bug to squash.
Milestone

Comments

@rkeithhill
Copy link
Contributor

In testing the ${file} way of specifying the file to debug, I'm noticing that for a file named foo[1].ps1 the breakpoint never hits - even though the script clearly executes. And while VSCode shows the file as having a breakpoint, if I run Get-PSBreakpoint in the dbg repl, it doesn't show up. My guess is that were we set the breakpoint file we probably need to use -LiteralPath instead of -Path.

@daviwil daviwil added this to the 0.4.0 milestone Feb 2, 2016
@daviwil daviwil added the Issue-Bug A bug to squash. label Feb 2, 2016
@daviwil
Copy link
Contributor

daviwil commented Feb 2, 2016

Hah, great catch!

@rkeithhill
Copy link
Contributor Author

@daviwil Check this out. Create a file in ISE - name it foo[1].ps1. Now put a few lines of script in it. Put the cursor on a valid line of script and press F9. Nothing!! No breakpoint. Turns out that Set-PSBreakpoint doesn't have a Path/LiteralPath set of parameters (bad, bad cmdlet). For files it has a -Script parameter that gets tripped up by globbing chars. If you try to set the breakpoint from ISE's command window, it smartly escapes the square brackets and puts the path in a string:

5> Set-PSBreakpoint -Script 'C:\Users\Keith\PowerShellSupport\foo`[1`].ps1' -Line 2

That works.

From the PowerShell prompt, only this combination seems to work (path in quotes and escaped brackets). Blech. The CompletionText for that path has the correctly quoted/escaped string. I wonder if we could somehow use that for processing file paths before passing them to Set-PSBreakpoint? Hmm...

@daviwil
Copy link
Contributor

daviwil commented Feb 2, 2016

Haha, using IntelliSense to resolve the path might be a little overkill, but we should definitely quote and escape any path that gets passed in. If you want to try the IntelliSense approach just to see how the code looks, go for it!

@rkeithhill
Copy link
Contributor Author

OK fixing it the right way should be easy. I believe the only wildcard chars we need to escape are [ and ].

@daviwil
Copy link
Contributor

daviwil commented Feb 2, 2016

Sounds good to me!

@rkeithhill rkeithhill self-assigned this Feb 3, 2016
rkeithhill added a commit to rkeithhill/PowerShellEditorServices that referenced this issue Feb 3, 2016
…reakpoints from working.

Once I got breakpoints to be able to set for files like foo[1].ps1 and foo][.ps1 I noticed that the script named foo][.ps1 would not execute at all!! You get an error saying something like the specified wildcard character pattern is not valid.  FWIW ISE fails with this same message.  So PSES has one up on ISE.  :-)
daviwil added a commit that referenced this issue Feb 3, 2016
…litpath

Fix for issue #123, wildcard chars in script path prevent breakpoints…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug A bug to squash.
Projects
None yet
Development

No branches or pull requests

2 participants