Last active
December 30, 2017 04:26
-
-
Save wbbradley/76e646c85be39abdb6d95a63f16af78b to your computer and use it in GitHub Desktop.
start of simple tee implementation
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
module tee | |
get sys | |
get file | |
def main() | |
if len(sys.args) == 2 | |
newline := "\n" | |
f := file.open(sys.args[1], "w") | |
state := f.state | |
when state | |
is file.Open | |
for line in readlines() | |
print(line) | |
file.write(f, line) | |
file.write(f, newline) | |
file.close(f) | |
is file.Error | |
print("Failed to open file " + sys.args[1] + ": error " + state.errno) | |
sys.exit(-1) | |
is file.Closed | |
print("Failed to open file " + sys.args[1]) | |
sys.exit(-1) | |
else | |
for line in readlines() | |
print(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment