Add tee utility

This commit is contained in:
joachimschmidt557 2019-03-27 11:14:08 +01:00
parent 3866bec55e
commit 761eb0a5e6
3 changed files with 24 additions and 4 deletions

11
cat.nim
View file

@ -3,8 +3,13 @@ import common
proc main(files:seq[string]) =
for file in files:
var s = newFileStream(file, fmRead)
while not s.atEnd:
write(stdout, s.readChar)
if file == "-":
var line = ""
while stdin.readLine(line):
echo line
else:
var s = newFileStream(file, fmRead)
while not s.atEnd:
write(stdout, s.readChar)
dispatch(main, version=("version", nimbaseVersion))