1 #!/usr/bin/env python3
2 #
3 # fontconfig/doc/run-quiet.py
4 #
5 # Runs command and discards anything it sends to stdout
6 #
7 # Copyright © 2020 Tim-Philipp Müller
8 #
9 # Permission to use, copy, modify, distribute, and sell this software and its
10 # documentation for any purpose is hereby granted without fee, provided that
11 # the above copyright notice appear in all copies and that both that
12 # copyright notice and this permission notice appear in supporting
13 # documentation, and that the name of the author(s) not be used in
14 # advertising or publicity pertaining to distribution of the software without
15 # specific, written prior permission. The authors make no
16 # representations about the suitability of this software for any purpose. It
17 # is provided "as is" without express or implied warranty.
18 #
19 # THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
20 # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
21 # EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
22 # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
23 # DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
24 # TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
25 # PERFORMANCE OF THIS SOFTWARE.
26 import subprocess
27 import sys
28 import os
29
30 if len(sys.argv) < 2:
31 sys.exit('Usage: {} PROGRAM [ARGS..]'.format(sys.argv[0]))
32
33 command = sys.argv[1:]
34
35 with open(os.devnull, 'w') as out:
36 sys.exit(subprocess.run(command, stdout=out).returncode)