question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Integrated console hangs if PSReadline sets AddToHistoryHandler

See original GitHub issue

I’m running preview but I think this may be in the release as well. psreadline can save your passwords to its plaintext log. To prevent this leeholmes put out a little fragment

        Set-PSReadLineOption -AddToHistoryHandler {
            param([string]$line)
            $sensitive = "password|asplaintext|token|key|secret"
            return ($line -notmatch $sensitive)
        }

I found this was hanging my Intergrated console (but not a PowerShell terminal) in VS Code.

easy to repro ensure you have the integrated console selected. Run a command. paste in Set-PSReadLineOption -AddToHistoryHandler {param([string]$line) return $true} Re-run the previous command

This may be a psreadline bug but it only occurs in the integrated console.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jhoneillcommented, Apr 13, 2022

@andschwa In the current version this problem has gone away. Obvious it’s been around for a while and I haven’t kept checking it so I can’t say if it was a recent change that fixed it but this can be closed now.

1reaction
rjmholtcommented, Jan 31, 2020

Thinking about this, we may need to override Set-PSReadLineOption to intercept parameters that run scriptblocks and turn them into callbacks back into PSES to run things on the pipeline thread.

However that’s rather complex, so I’m not going to attempt it immediately. Also, @daxian-dbw might have a better idea here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't set any value for AddToHistoryHandler in PowerShell
This property contains a script block which returns true or false. If the script block returns true, the value will be added to...
Read more >
Chapter 1. The PowerShell Interactive Shell - O'Reilly
This chapter introduces PowerShell from the perspective of its ... Stops a job. ... Use the Set-PSReadLineKeyHandler command to configure how PSReadLine ......
Read more >
Set-PSReadLineOption (PSReadLine) - PowerShell
-AddToHistoryHandler. Specifies a ScriptBlock that controls which commands get added to PSReadLine history. The ScriptBlock receives the command line as input.
Read more >
Making VS Code's Powershell Integrated Console useful
Let's take a look at the differences between the two, then look at how to improve the PIC. Types of Terminals. You can...
Read more >
https://raw.githubusercontent.com/redcanaryco/atom...
n\nMost Linux and Linux-based platforms provide a standard set of permission ... exist if the system is patched, if unpatched Microsoft Management Console...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found