aboutsummaryrefslogtreecommitdiffstats
path: root/build/scripts/cat.py
blob: 6153dd2a8a388198a3e16b43b9e321bd8e73116c (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))