Short-circuit calling tty if stdin is redirected
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from trezorlib.client import PASSPHRASE_ON_DEVICE
|
from trezorlib.client import PASSPHRASE_ON_DEVICE
|
||||||
@@ -76,6 +77,7 @@ class UI:
|
|||||||
def create_default_options_getter():
|
def create_default_options_getter():
|
||||||
"""Return current TTY and DISPLAY settings for GnuPG pinentry."""
|
"""Return current TTY and DISPLAY settings for GnuPG pinentry."""
|
||||||
options = []
|
options = []
|
||||||
|
if sys.stdin.isatty(): # short-circuit calling `tty`
|
||||||
try:
|
try:
|
||||||
ttyname = subprocess.check_output(args=['tty']).strip()
|
ttyname = subprocess.check_output(args=['tty']).strip()
|
||||||
options.append(b'ttyname=' + ttyname)
|
options.append(b'ttyname=' + ttyname)
|
||||||
|
|||||||
Reference in New Issue
Block a user