OILS / spec / bin / stdout_stderr.py View on Github | oilshell.org

34 lines, 20 significant
1#!/usr/bin/env python2
2from __future__ import print_function
3"""
4stdout_stderr.py
5
6Tool for testing redirects.
7"""
8
9import sys
10
11
12def main(argv):
13 try:
14 stdout = argv[1]
15 except IndexError:
16 stdout = 'STDOUT'
17
18 try:
19 stderr = argv[2]
20 except IndexError:
21 stderr = 'STDERR'
22
23 try:
24 status = int(argv[3])
25 except IndexError:
26 status = 0
27
28 print(stdout)
29 print(stderr, file=sys.stderr)
30 return status
31
32
33if __name__ == '__main__':
34 sys.exit(main(sys.argv))