Skip to content

Debug parameter now sets debugpreference to continue #8195

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

Merged
merged 4 commits into from
Nov 30, 2018

Conversation

KirkMunro
Copy link
Contributor

@KirkMunro KirkMunro commented Nov 6, 2018

PR Summary

This is bound to generate some discussion because it is a breaking change (but not to scripts -- it breaks current interactive behavior). With this PR in place, users who invoke a command with -Debug will no longer be presented with a prompt asking them if they want to enter a nested prompt, continue execution, or halt execution entirely. Instead, any messages sent to the debug stream will simply be sent to the debug stream and the script will continue execution. That is why this is identified as a breaking change, but only for interactive use.

As described in #7122, the current -Debug behavior dates back to PowerShell v1 and hasn't been useful since the debugger was introduced in PowerShell 2. It's time this functionality be made useful again, for all of the reasons identified in #7122 (so that we can actually have debug output from specific commands show up when they are invoked with -Debug without having to go through a bunch of unwanted prompts). See the details in the bug report to understand why this change is desired by members of the PowerShell Community.

PR Checklist

Copy link
Contributor

@PaulHigin PaulHigin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fully agree with this change. To me -Debug is much more useful as a data stream rather than a prompt.

@iSazonov
Copy link
Collaborator

iSazonov commented Nov 7, 2018

PowerShell-CI-Windows temporary failed. Restart it.

@iSazonov iSazonov self-assigned this Nov 7, 2018
@SteveL-MSFT SteveL-MSFT added Review - Committee The PR/Issue needs a review from the PowerShell Committee Breaking-Change breaking change that may affect users labels Nov 8, 2018
@KirkMunro KirkMunro mentioned this pull request Nov 15, 2018
11 tasks
@iSazonov iSazonov added the CL-Engine Indicates that a PR should be marked as an engine change in the Change Log label Nov 16, 2018
@SteveL-MSFT
Copy link
Member

@PowerShell/powershell-committee the current PR precludes the ability to opt into the current behavior to use Inquire. We agree that the default can be Continue, but we still need a way to allow users to use Inquire. Suggestion is to add -DebugAction to allow going back to current behavior for a specific cmdlet, however, that can be deferred until someone needs it.

@SteveL-MSFT SteveL-MSFT added Committee-Reviewed PS-Committee has reviewed this and made a decision and removed Review - Committee The PR/Issue needs a review from the PowerShell Committee labels Nov 28, 2018
@KirkMunro
Copy link
Contributor Author

If you happen to get such a request (someone asking for Inquire support), please tag me, I'd love to learn why someone wants that support.

@iSazonov iSazonov added the CL-BreakingChange Indicates that a PR should be marked as a breaking change in the Change Log label Nov 30, 2018
@iSazonov
Copy link
Collaborator

Is the PR ready to merge? If so @KirkMunro please update the PR description (breaking change is not mentioned).

@KirkMunro
Copy link
Contributor Author

@iSazonov: It is ready to merge, and I added more descriptive details to the first paragraph in the description to identify what would be breaking.

@iSazonov iSazonov changed the title -debug now sets debugpreference to continue Debug parameter now sets debugpreference to continue Nov 30, 2018
@iSazonov iSazonov merged commit e721f7b into PowerShell:master Nov 30, 2018
@iSazonov
Copy link
Collaborator

@KirkMunro Thanks for the great contribution!

@JeremyTBradshaw
Copy link

If you happen to get such a request (someone asking for Inquire support), please tag me, I'd love to learn why someone wants that support.

I am a little late jumping to PowerShell 7.1. Recently started to while I am using MS Graph and EWS Managed API and have no need for Windows PowerShell when doing so. I was caught off guard by this change, and am very used to -Debug resulting in Inquire. I found debugging this way, way easier than anything else. Debugging in VS Code seemed difficult and so I stuck with -Debug = Inquire.

I'm not necessarily opposed to the new way, but I would like to know where is some decent documentation on how to debug as easily. I really like to Suspend, jump in and investigate. It's how I hone in all my scripts and flush out errors. I don't like to just see streams of info blowing by, so really need that Suspend capability.

Please do share if you can. I'll also start researching on the topic. This is a doozy of a change indeed. If it means debugging the old way in a regular PowerShell console isn't possible, ouch.

@JeremyTBradshaw
Copy link

Actually, you know it's fine. I will just get used to it. I am a little lost on debugging in general so that's on me. I see how -ErrorAction Break is essentially what I need for replacing the older -Debug = Inquire in Windows PowerShell.

Using ErrorAction Break for the first time, the top 1/2 of the instructions were covered over by my frozen Write-Progress. And scrolling up, all the text is garbled. Quickly put my tail between my legs and just went back to Windows PowerShell. Saving this bit of learning for a future date.

@Samuli3682
Copy link

Samuli3682 commented Dec 3, 2020 via email

@KirkMunro
Copy link
Contributor Author

Hey @JeremyTBradshaw, thanks for responding back. I was really curious if there would be resistance among some folk, and the fact that you're responding rather than just silently complaining is very helpful.

I'm happy to help you out with this, either via back-and-forth texts, or a call on Microsoft Teams where we can screenshare and I could show you the ropes of the debugger. That would be helpful for me as well, to learn how you would like to use the debugger, and make sure that your needs are covered. Maybe the outcome of this will be a document describing what you're looking for: how to transition from -Debug's Inquire capability to the using the full power of the debugger without losing your mind in the process.

@KirkMunro
Copy link
Contributor Author

Using ErrorAction Break for the first time, the top 1/2 of the instructions were covered over by my frozen Write-Progress. And scrolling up, all the text is garbled. Quickly put my tail between my legs and just went back to Windows PowerShell. Saving this bit of learning for a future date.

For this, might I suggest setting $ProgressPreference = 'SilentlyContinue', and then running your script with -ErrorAction Break? That would prevent the progress window from appearing, which should help what you just tried a little. Anyway, if you want to do a call to discuss this and more, I'll be able to fast forward your learning quite a bit.

@KirkMunro
Copy link
Contributor Author

KirkMunro commented Dec 3, 2020

If it means debugging the old way in a regular PowerShell console isn't possible, ouch.

One last thing @JeremyTBradshaw: I do almost all of my debugging in a regular PowerShell console. Always have. Only rarely will I debug in an IDE like PowerShell ISE or VS Code. All to say, debugging in a regular PowerShell console works wonderfully.

You can also do old-school debugging in PowerShell 7 anytime you like. Simply set $DebugPreference = 'Inquire' and then run your script without -Debug, and when you do, you'll get the prompts that you are used to; however, it would be beneficial to learn the debugger itself and to understand how to leverage what it can do for you -- you'll be more efficient when you need to debug scripts as a result.

@JeremyTBradshaw
Copy link

If it means debugging the old way in a regular PowerShell console isn't possible, ouch.

One last thing @JeremyTBradshaw: I do almost all of my debugging in a regular PowerShell console. Always have. Only rarely will I debug in an IDE like PowerShell ISE or VS Code. All to say, debugging in a regular PowerShell console works wonderfully.

You can also do old-school debugging in PowerShell 7 anytime you like. Simply set $DebugPreference = 'Inquire' and then run your script without -Debug, and when you do, you'll get the prompts that you are used to; however, it would be beneficial to learn the debugger itself and to understand how to leverage what it can do for you -- you'll be more efficient when you need to debug scripts as a result.

Thanks for this. I would take you up on the Teams meeting offer if it still stands. Not sure when you had in mind but I've just exposed my email address on my GitHub profile and my tomorrow is currently open so if that works, that'd be great. I should be quick to pick it up, so really it won't be long, and I can quickly show you the way I've been using -Debug. The short version is that I commonly place Write-Debug's in my code wherever I'd like to jump in to troubleshoot or test, and then run with -Debug. Whereas you're confirming you do your proper debugging in the console, that is good to hear, so again, look forward to the chance to get a quick rundown on this.

Thanks!

@KirkMunro
Copy link
Contributor Author

@JeremyTBradshaw: Responded via the email address you shared, and we can work out a time through email.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking-Change breaking change that may affect users CL-BreakingChange Indicates that a PR should be marked as a breaking change in the Change Log CL-Engine Indicates that a PR should be marked as an engine change in the Change Log Committee-Reviewed PS-Committee has reviewed this and made a decision
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants