fix: stdin interactivity check (#1271)

Signed-off-by: Matej Vasek <mvasek@redhat.com>

Signed-off-by: Matej Vasek <mvasek@redhat.com>
This commit is contained in:
Matej Vasek 2022-09-22 15:13:12 +02:00 committed by GitHub
parent 56b56a5559
commit d038f6c73e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -12,6 +12,7 @@ import (
"github.com/ory/viper"
"github.com/spf13/cobra"
"golang.org/x/term"
"k8s.io/apimachinery/pkg/util/sets"
"knative.dev/client/pkg/util"
fn "knative.dev/kn-plugin-func"
@ -131,8 +132,7 @@ EXAMPLES
// terminal is interactive. Used for determining whether or not to
// interactively prompt the user to confirm default choices, etc.
func interactiveTerminal() bool {
fi, err := os.Stdin.Stat()
return err == nil && ((fi.Mode() & os.ModeCharDevice) != 0)
return term.IsTerminal(int(os.Stdin.Fd()))
}
// bindFunc which conforms to the cobra PreRunE method signature