Integrated console hangs if PSReadline sets AddToHistoryHandler
See original GitHub issueI’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:
- Created 4 years ago
- Reactions:2
- Comments:7 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@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.
Thinking about this, we may need to override
Set-PSReadLineOptionto 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.