Last active
November 13, 2017 11:49
-
-
Save icatalina/3708c320aa0260a9fa7532a5b6bc5d96 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python2 | |
""" | |
Processes an stdin and prompts for confirmation | |
""" | |
import sys | |
def process(): | |
""" | |
Processes an stdin and prompts for confirmation | |
""" | |
input_value = sys.stdin.read() | |
sys.stdin = open('/dev/tty') | |
old_stdout = sys.stdout | |
try: | |
sys.stdout = sys.stderr | |
print input_value.strip() | |
selected_option = raw_input('Continue (y/N)? ') | |
finally: | |
sys.stdout = old_stdout | |
if selected_option == 'y': | |
print input_value | |
else: | |
sys.exit(1) | |
process() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment