-
Notifications
You must be signed in to change notification settings - Fork 55
Open
Description
I found that on Windows, if a console is generated from stderr, output sent towards the console will go into stdout with extra warning like .failed to get console mode for stdout: The handle is invalid.(resovled in 7b7885a)
Verified this with a simple test program in here which simply outputs three messages
// 1. generate console from stderr
c, err := console.ConsoleFromFile(os.Stderr)
if err != nil {
fmt.Println("failed to generate console from stderr", err)
os.Exit(1)
}
// 2. output to stderr, stdout and console
fmt.Fprintln(os.Stderr, "via os.Stderr")
fmt.Fprintln(os.Stdout, "via os.Stdout")
fmt.Fprintln(c, "via stderr console")In Powershell, the output is like:
> $a=.\console.exe
via os.Stderr
> $a
failed to get console mode for stdout: The handle is invalid.
via os.Stdout
via stderr console The via stderr console log goes wrongly into the variable $a (which should only contain the command's success output stream and stdout output).
As a comparison, below is the behavior of the test program on Zsh(Ubuntu 20.04)
> a=$(./console)
via os.Stderr
via stderr console
> echo $a
via os.StdoutWe can see tht the via stderr console doesn't goes into the stdout output as expected.
Metadata
Metadata
Assignees
Labels
No labels