From 7cf3df20e15f1d718d03d4ac5dd09d636417093f Mon Sep 17 00:00:00 2001 From: ickyicky Date: Sun, 11 Jul 2021 01:22:46 +0200 Subject: [PATCH] fixed problem with piping --- README.md | 6 +----- fasttyper/__main__.py | 5 ++++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 88ec3c7..9455c7a 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,4 @@ Program also allows user to pipe text into it. Keep in mind, it only supports sp # Known issues -_Fasttyper_ relies on curses library, so in order to allow it to first read piped text and then read characters from terminal users have to exec: - -`exec 3<&0` - -in their terminal before piping text to _Fasttyper_, duplicating stdin to descriptor 3. +Too large text brakes the app. diff --git a/fasttyper/__main__.py b/fasttyper/__main__.py index 9806f91..6f27c31 100644 --- a/fasttyper/__main__.py +++ b/fasttyper/__main__.py @@ -59,7 +59,10 @@ def main(): rbuffer = io.StringIO(f.read()) else: input_lines = sys.stdin.readlines() - os.dup2(3, 0) + + with open("/dev/tty") as f: + os.dup2(f.fileno(), 0) + rbuffer = io.StringIO("".join(input_lines)) try: