aboutsummaryrefslogtreecommitdiffstats
path: root/build/scripts/cat.py
blob: 0c3f73d96f66359bcfd951f187561ce59a23a509 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env python
import sys
from shutil import copyfileobj as copy
import os.path

if __name__ == '__main__':
    for filename in sys.argv[1:] or ["-"]:
        if filename == "-":
            copy(sys.stdin, sys.stdout)
        else:
            if os.path.exists(filename):
                with open(filename, 'rb') as file:
                    copy(file, sys.stdout)
            else:
                sys.stderr.write('cat.py: {0}: No such file or directory\n'.format(filename))