-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy patheol
More file actions
executable file
·31 lines (26 loc) · 730 Bytes
/
eol
File metadata and controls
executable file
·31 lines (26 loc) · 730 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3
import os
import sys
def run(in_stream, out_stream):
trailing_eof = False
while True:
data = in_stream.read(2048)
if not data:
if not trailing_eof:
out_stream.write('\n')
break
out_stream.write(data)
if data[-1] == '\n':
trailing_eof = True
else:
trailing_eof = False
if __name__ == '__main__':
basename = os.path.basename(sys.argv[0])
try:
run(sys.stdin, sys.stdout)
except KeyboardInterrupt:
sys.stderr.write('\n')
sys.exit(130)
except IOError as e:
sys.stderr.write("%s: %s: %s\n" % (basename, e.filename, e.strerror))
sys.exit(1)