terminal, log: rename TerminalOutput to RawOut

it was confusing to have a terminal.Out along with a TerminalOutput
This commit is contained in:
Carl Edquist 2022-10-06 16:42:22 -05:00
parent 0687a263f8
commit cec47699d3
2 changed files with 4 additions and 4 deletions

View File

@ -19,7 +19,7 @@ func redirectStderr(f *os.File) {
if err != nil { if err != nil {
log.Fatalf("Failed to duplicate stderr: %v", err) log.Fatalf("Failed to duplicate stderr: %v", err)
} }
terminal.TerminalOutput = os.NewFile(uintptr(passPromptFd), "passPrompt") terminal.RawOut = os.NewFile(uintptr(passPromptFd), "passPrompt")
err = unix.Dup2(int(f.Fd()), int(os.Stderr.Fd())) err = unix.Dup2(int(f.Fd()), int(os.Stderr.Fd()))
if err != nil { if err != nil {
log.Fatalf("Failed to redirect stderr to file: %v", err) log.Fatalf("Failed to redirect stderr to file: %v", err)

View File

@ -69,14 +69,14 @@ var (
// make sure that start is only called once // make sure that start is only called once
once sync.Once once sync.Once
// TerminalOutput is for password prompt progress output // RawOut is the underlying *os.File intended for terminal output
TerminalOutput = os.Stderr RawOut = os.Stderr
) )
// Start the terminal - must be called before use // Start the terminal - must be called before use
func Start() { func Start() {
once.Do(func() { once.Do(func() {
f := TerminalOutput f := RawOut
if !IsTerminal(int(f.Fd())) { if !IsTerminal(int(f.Fd())) {
// If output is not a tty then remove escape codes // If output is not a tty then remove escape codes
Out = colorable.NewNonColorable(f) Out = colorable.NewNonColorable(f)