mirror of
https://github.com/containers/podman.git
synced 2025-06-25 20:26:51 +08:00
Merge pull request #9747 from rhatdan/tty
Check if stdin is a term in --interactive --tty mode
This commit is contained in:
@ -17,6 +17,7 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"golang.org/x/crypto/ssh/terminal"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -106,6 +107,11 @@ func run(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Breaking change should be made fatal in next major Release
|
||||||
|
if cliVals.TTY && cliVals.Interactive && !terminal.IsTerminal(int(os.Stdin.Fd())) {
|
||||||
|
logrus.Warnf("The input device is not a TTY. The --tty and --interactive flags might not work properly")
|
||||||
|
}
|
||||||
|
|
||||||
if af := cliVals.Authfile; len(af) > 0 {
|
if af := cliVals.Authfile; len(af) > 0 {
|
||||||
if _, err := os.Stat(af); err != nil {
|
if _, err := os.Stat(af); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -668,4 +668,15 @@ json-file | f
|
|||||||
is "$output" ".*HOME=/.*"
|
is "$output" ".*HOME=/.*"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "podman run --tty -i failure with no tty" {
|
||||||
|
run_podman run --tty -i --rm $IMAGE echo hello < /dev/null
|
||||||
|
is "$output" ".*The input device is not a TTY.*"
|
||||||
|
|
||||||
|
run_podman run --tty=false -i --rm $IMAGE echo hello < /dev/null
|
||||||
|
is "$output" "hello"
|
||||||
|
|
||||||
|
run_podman run --tty -i=false --rm $IMAGE echo hello < /dev/null
|
||||||
|
is "$output" "hello"
|
||||||
|
}
|
||||||
|
|
||||||
# vim: filetype=sh
|
# vim: filetype=sh
|
||||||
|
Reference in New Issue
Block a user