Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/action/otp.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (s *Action) otp(ctx context.Context, name, qrf string, clip, pw, recurse bo
ctx, cancel := context.WithCancel(ctx)
defer cancel()

skip := ctxutil.IsHidden(ctx) || pw || qrf != "" || out.OutputIsRedirected() || !ctxutil.IsInteractive(ctx) || clip
skip := ctxutil.IsHidden(ctx) || pw || qrf != "" || !ctxutil.IsTerminal(ctx) || !ctxutil.IsInteractive(ctx) || clip
if !skip {
// let us monitor key presses for cancellation:.
go waitForKeyPress(ctx, cancel)
Expand Down Expand Up @@ -128,7 +128,7 @@ func (s *Action) otp(ctx context.Context, name, qrf string, clip, pw, recurse bo
}

// check if we are in "password only" or in "qr code" mode or being redirected to a pipe.
if pw || qrf != "" || out.OutputIsRedirected() {
if pw || qrf != "" || !ctxutil.IsTerminal(ctx) {
out.Printf(ctx, "%s", token)
cancel()
} else { // if not then we want to print a progress bar with the expiry time.
Expand Down
7 changes: 0 additions & 7 deletions internal/out/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ func (s Secret) SafeStr() string {
return "(elided)"
}

// OutputIsRedirected returns true if the current os.Stdout is a pipe instead of a terminal.
func OutputIsRedirected() bool {
o, _ := os.Stdout.Stat()

return (o.Mode() & os.ModeCharDevice) != os.ModeCharDevice
}

func newline(ctx context.Context) string {
if HasNewline(ctx) {
return "\n"
Expand Down