Merge pull request #29288 from Microsoft/jjh/promptusestdin

Windows: Prompt fix use regular stdin
Upstream-commit: 5665c7364241e451a507a9e8024b6a8b43675527
Component: engine
This commit is contained in:
Vincent Demeester
2016-12-13 21:18:54 +01:00
committed by GitHub
+6
View File
@@ -6,6 +6,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"runtime"
"strings"
)
@@ -71,6 +72,11 @@ func PromptForConfirmation(ins *InStream, outs *OutStream, message string) bool
fmt.Fprintf(outs, message)
// On Windows, force the use of the regular OS stdin stream.
if runtime.GOOS == "windows" {
ins = NewInStream(os.Stdin)
}
answer := ""
n, _ := fmt.Fscan(ins, &answer)
if n != 1 || (answer != "y" && answer != "Y") {