$ nim c ttytest.nim
$ ./ttytest | nl
こっちはnlされない
1 こっちはnlされる
Last active
November 4, 2019 06:15
-
-
Save jiro4989/6041d2d366d379a7af29b29283b5f6ec to your computer and use it in GitHub Desktop.
Stop output stream to pipe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| var tty = open("/dev/tty", fmReadWrite) | |
| var oldStdin = stdin | |
| var oldStdout = stdout | |
| var oldStderr = stderr | |
| stdin = tty | |
| stdout = tty | |
| stderr = tty | |
| echo "こっちはnlされない" | |
| tty.close() | |
| stdin = oldStdin | |
| stdout = oldStdout | |
| stderr = oldStderr | |
| echo "こっちはnlされる" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment