From 904fa023c5a0a686fcf73ebae63b376a71eab168 Mon Sep 17 00:00:00 2001 From: anseki Date: Mon, 31 Aug 2015 16:46:58 +0900 Subject: [PATCH] Add comment in read.ps1 --- lib/read.ps1 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/read.ps1 b/lib/read.ps1 index c95b712..c5b931b 100644 --- a/lib/read.ps1 +++ b/lib/read.ps1 @@ -45,18 +45,18 @@ foreach ($arg in $argList) { # **NOTE** Don't include special characters of DOS in $command when $getRes is True. # [string] $cmdPath = $Env:ComSpec # [string] $psPath = 'powershell.exe' -function execWithTTY ($command, $getRes = $False, $errorThrow = $False) { +function execWithTTY ($command, $getRes = $False, $throwError = $False) { if ($getRes) { $res = (cmd.exe /C "CON powershell.exe -Command -" if ($LastExitCode -ne 0) { - if ($errorThrow) { throw $LastExitCode } + if ($throwError) { throw $LastExitCode } else { exit $LastExitCode } } } @@ -73,6 +73,7 @@ if ($options.display) { if ($options.displayOnly) { return "''" } if (-not $options.keyIn -and $options.hideEchoBack -and $options.mask -eq '*') { + # It fails when it's not ready. try { $inputTTY = execWithTTY ('$text = Read-Host -AsSecureString;' + '$bstr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($text);' +